From 6aedc4b147b6dd6bb65c51b0e11512c3984178a1 Mon Sep 17 00:00:00 2001 From: Kenneth Ito Date: Mon, 15 Apr 2024 08:19:00 -0700 Subject: [PATCH 1/2] Set connection transport buffer for active socket --- lib/xandra.ex | 3 +++ lib/xandra/connection.ex | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/xandra.ex b/lib/xandra.ex index 3b49474e..5f2d6164 100644 --- a/lib/xandra.ex +++ b/lib/xandra.ex @@ -449,6 +449,9 @@ defmodule Xandra do 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). + + Of note is the `:buffer` option (positive integer), which controls the size of the + user level buffer in use by the active mode socket. It is defaulted to 1_000_000 bytes. """ ], diff --git a/lib/xandra/connection.ex b/lib/xandra/connection.ex index 1c284f23..8e933833 100644 --- a/lib/xandra/connection.ex +++ b/lib/xandra/connection.ex @@ -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) @@ -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) } From f0818c3c7a6f2c5d9957ff1201785b9b96fdc65a Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Tue, 16 Apr 2024 19:40:18 +0200 Subject: [PATCH 2/2] Update lib/xandra.ex --- lib/xandra.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/xandra.ex b/lib/xandra.ex index 5f2d6164..a4f0087e 100644 --- a/lib/xandra.ex +++ b/lib/xandra.ex @@ -448,10 +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). - - Of note is the `:buffer` option (positive integer), which controls the size of the - user level buffer in use by the active mode socket. It is defaulted to 1_000_000 bytes. + 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. """ ],