Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set connection transport buffer for active socket #363

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/xandra.ex
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading