Skip to content

Commit 8e2ae63

Browse files
committed
Don't require BS_Module on checkin or checkout connection
1 parent 95074b9 commit 8e2ae63

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/elysium_buffering_strategy.erl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
-export([
3939
status/1,
4040

41-
create_connection/4,
41+
create_connection/3,
4242
checkin_connection/4,
43-
checkout_connection/2,
43+
checkout_connection/1,
4444
pend_request/2,
4545

4646
decay_causes_death/2,
@@ -74,13 +74,13 @@
7474
%%% Buffering strategy provided functions
7575
%%%-----------------------------------------------------------------------
7676

77-
-spec create_connection(config_type(), buffering_strategy_module(), cassandra_node(), connection_id())
77+
-spec create_connection(config_type(), cassandra_node(), connection_id())
7878
-> pending_checkin().
7979

8080
-spec checkin_connection(config_type(), cassandra_node(), connection_id(), Is_New_Connection::boolean())
8181
-> pending_checkin().
8282

83-
-spec checkout_connection(config_type(), buffering_strategy_module()) -> cassandra_connection() | none_available.
83+
-spec checkout_connection(config_type()) -> cassandra_connection() | none_available.
8484

8585
-spec pend_request(config_type(), query_request()) -> query_result().
8686

@@ -94,8 +94,9 @@
9494
Max_Or_Timeout :: max_connections() | timeout_in_ms().
9595

9696
%% @doc Do any initialization before checkin of a newly created connection.
97-
create_connection(Config, BS_Module, {_Ip, _Port} = Node, Connection_Id)
97+
create_connection(Config, {_Ip, _Port} = Node, Connection_Id)
9898
when is_pid(Connection_Id) ->
99+
{_Buffering_Strategy, BS_Module} = elysium_connection:get_buffer_strategy_module(Config),
99100
elysium_buffering_audit:audit_data_init(Config, BS_Module, Connection_Id),
100101
checkin_connection(Config, Node, Connection_Id, true).
101102

@@ -126,7 +127,7 @@ checkin_connection(Config, {_Ip, _Port} = Node, Connection_Id, Is_New_Connection
126127
%% function should be a hotspot and we don't want it to slow
127128
%% down or become a concurrency bottleneck.
128129
%% @end
129-
checkout_connection(Config, BS_Module) ->
130+
checkout_connection(Config) ->
130131
Connection_Queue = elysium_config:session_queue_name (Config),
131132
Max_Retries = elysium_config:checkout_max_retry (Config),
132133
{_BS, BS_Module} = elysium_connection:get_buffer_strategy_module (Config),

src/elysium_connection.erl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ get_buffer_strategy_module(Config) ->
131131
with_connection(Config, Session_Fun, Args, Consistency)
132132
when is_function(Session_Fun, 3), is_list(Args) ->
133133
{Buffering_Strategy, BS_Module} = get_buffer_strategy_module(Config),
134-
case elysium_buffering_strategy:checkout_connection(Config, BS_Module) of
134+
case elysium_buffering_strategy:checkout_connection(Config) of
135135
none_available ->
136136
buffer_bare_fun_call(Config, Session_Fun, Args, Consistency, Buffering_Strategy);
137137
{Node, Sid} when is_pid(Sid) ->
@@ -156,7 +156,7 @@ with_connection(Config, Mod, Fun, Args, Consistency)
156156
when is_atom(Mod), is_atom(Fun), is_list(Args) ->
157157
true = erlang:function_exported(Mod, Fun, 3),
158158
{Buffering_Strategy, BS_Module} = get_buffer_strategy_module(Config),
159-
case elysium_buffering_strategy:checkout_connection(Config, BS_Module) of
159+
case elysium_buffering_strategy:checkout_connection(Config) of
160160
none_available ->
161161
buffer_mod_fun_call(Config, Mod, Fun, Args, Consistency, Buffering_Strategy);
162162
{Node, Sid} when is_pid(Sid) ->
@@ -209,8 +209,7 @@ try_connect(Config, Lb_Queue_Name, Max_Retries, Times_Tried, Attempted_Connectio
209209
[{connect_timeout, Connect_Timeout}]) of
210210

211211
{ok, Connection_Id} = Connection when is_pid(Connection_Id) ->
212-
{_Buffering_Strategy, BS_Module} = get_buffer_strategy_module(Config),
213-
_ = elysium_buffering_strategy:create_connection(Config, BS_Module, Node, Connection_Id),
212+
_ = elysium_buffering_strategy:create_connection(Config, Node, Connection_Id),
214213
Connection;
215214

216215
%% If we fail, try again after recording attempt.

0 commit comments

Comments
 (0)