Skip to content

Commit

Permalink
Set connection transport buffer for active socket (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrea Leopardi <an.leopardi@gmail.com>
  • Loading branch information
kennethito and whatyouhide committed Apr 16, 2024
1 parent 077cc5f commit 820c34d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/xandra.ex
Expand Up @@ -448,7 +448,9 @@ defmodule Xandra do
doc: """
Options to forward to the socket transport. If the `:encryption` option is `true`,
then the transport is SSL (see the Erlang `:ssl` module) otherwise it's
TCP (see the `:gen_tcp` Erlang module).
TCP (see the `:gen_tcp` Erlang module). The `:buffer` option (`t:pos_integer/0`),
which controls the size of the user level buffer in use by the active mode
socket, defaults to `1_000_000` bytes.
"""
],

Expand Down
5 changes: 5 additions & 0 deletions lib/xandra/connection.ex
Expand Up @@ -19,6 +19,10 @@ defmodule Xandra.Connection do

@forced_transport_options [packet: :raw, mode: :binary, active: false]

# The default size of the user-level buffer used by the driver
# We will receive at most this many bytes from the active mode socket
@default_transport_buffer_size 1_000_000

# How old a timed-out stream ID can be before we flush it.
@max_timed_out_stream_id_age_in_millisec :timer.minutes(5)

Expand Down Expand Up @@ -410,6 +414,7 @@ defmodule Xandra.Connection do
options:
options
|> Keyword.get(:transport_options, [])
|> Keyword.put_new(:buffer, @default_transport_buffer_size)
|> Keyword.merge(@forced_transport_options)
}

Expand Down

0 comments on commit 820c34d

Please sign in to comment.