Skip to content

Commit 278d09c

Browse files
[AUTO] [ RTI-14085 ] Update Dependencies (#112)
* Update dependencies * [update-deps] Thank you, Elvis! --------- Co-authored-by: Brujo Benavides Rodriguez <elbrujohalcon@gmail.com>
1 parent 33808a9 commit 278d09c

6 files changed

Lines changed: 54 additions & 45 deletions

File tree

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
{project_plugins,
3131
[{rebar3_hex, "~> 7.0.4"},
3232
{rebar3_format, "~> 1.2.1"},
33-
{rebar3_lint, "~> 2.0.1"},
33+
{rebar3_lint, "~> 3.0.0"},
3434
{rebar3_hank, "~> 1.3.0"}]}.

src/mero_conf.erl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747

4848
-type per_pool_config_value(Type) ::
4949
{by_pool, Default :: Type, [{Pool :: atom(), Value :: Type}]}.
50-
-type mero_conf_value(Type) :: Type | per_pool_config_value(Type).
50+
-type value(Type) :: Type | per_pool_config_value(Type).
51+
52+
-export_type([value/1]).
5153

5254
%%%=============================================================================
5355
%%% External functions
@@ -88,7 +90,7 @@ cluster_config(ClusterConfig) ->
8890
pool_initial_connections(Pool) ->
8991
get_env_per_pool(initial_connections_per_pool, Pool).
9092

91-
-spec initial_connections_per_pool(Initial :: mero_conf_value(integer())) -> ok.
93+
-spec initial_connections_per_pool(Initial :: value(integer())) -> ok.
9294
initial_connections_per_pool(Initial) ->
9395
application:set_env(mero, initial_connections_per_pool, Initial).
9496

@@ -99,7 +101,7 @@ initial_connections_per_pool(Initial) ->
99101
pool_min_free_connections(Pool) ->
100102
get_env_per_pool(min_free_connections_per_pool, Pool).
101103

102-
-spec min_free_connections_per_pool(MinFree :: mero_conf_value(integer())) -> ok.
104+
-spec min_free_connections_per_pool(MinFree :: value(integer())) -> ok.
103105
min_free_connections_per_pool(MinFree) ->
104106
application:set_env(mero, min_free_connections_per_pool, MinFree).
105107

@@ -108,7 +110,7 @@ min_free_connections_per_pool(MinFree) ->
108110
pool_max_connections(Pool) ->
109111
get_env_per_pool(max_connections_per_pool, Pool).
110112

111-
-spec max_connections_per_pool(Max :: mero_conf_value(integer())) -> ok.
113+
-spec max_connections_per_pool(Max :: value(integer())) -> ok.
112114
max_connections_per_pool(Max) ->
113115
application:set_env(mero, max_connections_per_pool, Max).
114116

@@ -117,7 +119,7 @@ max_connections_per_pool(Max) ->
117119
pool_timeout_read(Pool) ->
118120
get_env_per_pool(timeout_read, Pool).
119121

120-
-spec timeout_read(Timeout :: mero_conf_value(integer())) -> ok.
122+
-spec timeout_read(Timeout :: value(integer())) -> ok.
121123
timeout_read(Timeout) ->
122124
application:set_env(mero, timeout_read, Timeout).
123125

@@ -126,7 +128,7 @@ timeout_read(Timeout) ->
126128
pool_timeout_write(Pool) ->
127129
get_env_per_pool(timeout_write, Pool).
128130

129-
-spec timeout_write(Timeout :: mero_conf_value(integer())) -> ok.
131+
-spec timeout_write(Timeout :: value(integer())) -> ok.
130132
timeout_write(Timeout) ->
131133
application:set_env(mero, timeout_write, Timeout).
132134

@@ -135,7 +137,7 @@ timeout_write(Timeout) ->
135137
pool_write_retries(Pool) ->
136138
get_env_per_pool(write_retries, Pool).
137139

138-
-spec write_retries(Timeout :: mero_conf_value(integer())) -> ok.
140+
-spec write_retries(Timeout :: value(integer())) -> ok.
139141
write_retries(Timeout) ->
140142
application:set_env(mero, write_retries, Timeout).
141143

@@ -144,7 +146,7 @@ write_retries(Timeout) ->
144146
pool_key_expiration_time(Pool) ->
145147
get_env_per_pool(expiration_time, Pool).
146148

147-
-spec key_expiration_time(Time :: mero_conf_value(integer())) -> ok.
149+
-spec key_expiration_time(Time :: value(integer())) -> ok.
148150
key_expiration_time(Time) ->
149151
application:set_env(mero, expiration_time, Time).
150152

@@ -153,7 +155,7 @@ key_expiration_time(Time) ->
153155
pool_expiration_interval(Pool) ->
154156
get_env_per_pool(expiration_interval, Pool).
155157

156-
-spec expiration_interval(mero_conf_value(integer())) -> ok.
158+
-spec expiration_interval(value(integer())) -> ok.
157159
expiration_interval(Val) ->
158160
application:set_env(mero, expiration_interval, Val).
159161

@@ -162,7 +164,7 @@ expiration_interval(Val) ->
162164
pool_connection_unused_max_time(Pool) ->
163165
get_env_per_pool(connection_unused_max_time, Pool).
164166

165-
-spec connection_unused_max_time(mero_conf_value(integer())) -> ok.
167+
-spec connection_unused_max_time(value(integer())) -> ok.
166168
connection_unused_max_time(Val) ->
167169
application:set_env(mero, connection_unused_max_time, Val).
168170

@@ -182,7 +184,7 @@ pool_min_connection_interval(Pool) ->
182184
undefined
183185
end.
184186

185-
-spec max_connection_delay_time(mero_conf_value(integer())) -> ok.
187+
-spec max_connection_delay_time(value(integer())) -> ok.
186188
max_connection_delay_time(Val) ->
187189
application:set_env(mero, max_connection_delay_time, Val).
188190

src/mero_conf_monitor.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,26 @@
2828
%%
2929
-module(mero_conf_monitor).
3030

31+
%% @todo Remove once https://github.com/inaka/elvis_core/issues/308 is dealt with
32+
-elvis([{elvis_style, export_used_types, disable}]).
33+
3134
-behaviour(gen_server).
3235

3336
-export([start_link/1, init/1, handle_call/3, handle_cast/2, handle_info/2,
3437
handle_continue/2]).
3538

3639
-record(state,
37-
{orig_config :: cluster_config(),
38-
processed_config :: cluster_config(),
40+
{orig_config :: mero:cluster_config(),
41+
processed_config :: mero:cluster_config(),
3942
cluster_version :: undefined | pos_integer()}).
4043

4144
-type state() :: #state{}.
42-
-type cluster_config() :: mero:cluster_config().
43-
-type init_args() :: #{orig_config := cluster_config()}.
45+
-type init_args() :: #{orig_config := mero:cluster_config()}.
4446

4547
%%%-----------------------------------------------------------------------------
4648
%%% API
4749
%%%-----------------------------------------------------------------------------
48-
-spec start_link(cluster_config()) -> {ok, pid()} | ignore | {error, term()}.
50+
-spec start_link(mero:cluster_config()) -> {ok, pid()} | ignore | {error, term()}.
4951
start_link(OrigConfig) ->
5052
gen_server:start_link({local, ?MODULE}, ?MODULE, #{orig_config => OrigConfig}, []).
5153

src/mero_pool.erl

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
worker_module :: module(),
5252
client :: client()}).
5353

54-
-type conn() :: #conn{}.
54+
-opaque conn() :: #conn{}.
55+
56+
-export_type([conn/0]).
5557

5658
-record(pool_st,
5759
{cluster,
@@ -115,21 +117,20 @@ checkout(PoolName, TimeLimit) ->
115117
end.
116118

117119
%% @doc Return a connection to specified pool updating its timestamp
118-
-spec checkin(Connection :: conn()) -> ok.
120+
-spec checkin(conn()) -> ok.
119121
checkin(#conn{pool = PoolName} = Connection) ->
120122
safe_send(PoolName, {checkin, self(), Connection#conn{updated = os:timestamp()}}),
121123
ok.
122124

123125
%% @doc Return a connection that has been closed.
124-
-spec checkin_closed(Connection :: conn()) -> ok.
126+
-spec checkin_closed(conn()) -> ok.
125127
checkin_closed(#conn{pool = PoolName}) ->
126128
safe_send(PoolName, {checkin_closed, self()}),
127129
ok.
128130

129131
%% @doc Executes an operation
130132

131-
-spec transaction(Connection :: conn(), atom(), list()) ->
132-
{NewConnection :: conn(), {ok, any()}} | {error, any()}.
133+
-spec transaction(conn(), atom(), list()) -> {conn(), {ok, any()}} | {error, any()}.
133134
transaction(#conn{worker_module = WorkerModule, client = Client} = Conn,
134135
Function,
135136
Args) ->
@@ -140,6 +141,7 @@ transaction(#conn{worker_module = WorkerModule, client = Client} = Conn,
140141
{Conn#conn{client = NClient}, Res}
141142
end.
142143

144+
-spec close(conn(), term()) -> _.
143145
close(#conn{worker_module = WorkerModule, client = Client}, Reason) ->
144146
WorkerModule:close(Client, Reason).
145147

@@ -163,10 +165,10 @@ init(Parent, ClusterName, Host, Port, PoolName, WrkModule) ->
163165
process_flag(trap_exit, true),
164166
Deb = sys:debug_options([]),
165167
{Module, Function} = mero_conf:stat_callback(),
166-
CallBackInfo =
168+
CallbackInfo =
167169
{Module, Function, [{cluster_name, ClusterName}, {host, Host}, {port, Port}]},
168170
Initial = mero_conf:pool_initial_connections(ClusterName),
169-
spawn_connections(ClusterName, PoolName, WrkModule, Host, Port, CallBackInfo, Initial),
171+
spawn_connections(ClusterName, PoolName, WrkModule, Host, Port, CallbackInfo, Initial),
170172
proc_lib:init_ack(Parent, {ok, self()}),
171173
State =
172174
#pool_st{cluster = ClusterName,
@@ -183,7 +185,7 @@ init(Parent, ClusterName, Host, Port, PoolName, WrkModule) ->
183185
%% If a connection attempt fails, or a connection is broken
184186
reconnect_wait_time = 200,
185187
pool = PoolName,
186-
callback_info = CallBackInfo,
188+
callback_info = CallbackInfo,
187189
worker_module = WrkModule,
188190
last_connection_attempt = 0},
189191
timer:send_interval(5000, reload_pool_min_max_settings),
@@ -297,18 +299,18 @@ maybe_spawn_connect(#pool_st{free = Free,
297299
%% - There is minimum interval between connections, and that hasn't elapsed yet since the last
298300
%% connection
299301
%% - There are in-flight connection attempts
300-
maybe_spawn_connect(State =
301-
#pool_st{min_connection_interval_ms = Min,
302-
last_connection_attempt = Last,
303-
num_connecting = Connecting},
302+
maybe_spawn_connect(#pool_st{min_connection_interval_ms = Min,
303+
last_connection_attempt = Last,
304+
num_connecting = Connecting} =
305+
State,
304306
Needed,
305307
Now)
306308
when Min /= undefined, Now - Last < Min; Connecting > 0; Needed == 0 ->
307309
State;
308-
maybe_spawn_connect(State =
309-
#pool_st{num_failed_connecting = NumFailed,
310-
reconnect_wait_time = WaitTime,
311-
num_connecting = Connecting},
310+
maybe_spawn_connect(#pool_st{num_failed_connecting = NumFailed,
311+
reconnect_wait_time = WaitTime,
312+
num_connecting = Connecting} =
313+
State,
312314
_Needed,
313315
_Now)
314316
when NumFailed > 0 ->
@@ -317,14 +319,14 @@ maybe_spawn_connect(State =
317319
%% one connection until an attempt has succeeded again.
318320
erlang:send_after(WaitTime, self(), connect),
319321
State#pool_st{num_connecting = Connecting + 1};
320-
maybe_spawn_connect(State =
321-
#pool_st{num_connecting = Connecting,
322-
pool = Pool,
323-
worker_module = WrkModule,
324-
cluster = ClusterName,
325-
host = Host,
326-
port = Port,
327-
callback_info = CallbackInfo},
322+
maybe_spawn_connect(#pool_st{num_connecting = Connecting,
323+
pool = Pool,
324+
worker_module = WrkModule,
325+
cluster = ClusterName,
326+
host = Host,
327+
port = Port,
328+
callback_info = CallbackInfo} =
329+
State,
328330
Needed,
329331
Now) ->
330332
spawn_connections(ClusterName, Pool, WrkModule, Host, Port, CallbackInfo, Needed),
@@ -453,7 +455,7 @@ conn_time_to_live(ClusterName) ->
453455
Milliseconds * 1000
454456
end.
455457

456-
schedule_expiration(State = #pool_st{cluster = ClusterName}) ->
458+
schedule_expiration(#pool_st{cluster = ClusterName} = State) ->
457459
erlang:send_after(
458460
mero_conf:pool_expiration_interval(ClusterName), self(), expire),
459461
State.
@@ -500,7 +502,7 @@ filter_expired(#conn{updated = Updated} = Conn, {Now, TTL, ExpConns, ActConns})
500502
%% If current # of connections > new max_connections, no action is taken to
501503
%% close the exceeding ones. Instead, they won't be re-created once they
502504
%% terminate by themselves (because of timeouts, errors, inactivity, etc)
503-
reload_pool_min_max_settings(State = #pool_st{cluster = ClusterName}) ->
505+
reload_pool_min_max_settings(#pool_st{cluster = ClusterName} = State) ->
504506
State#pool_st{min_connections = mero_conf:pool_min_free_connections(ClusterName),
505507
max_connections = mero_conf:pool_max_connections(ClusterName),
506508
min_connection_interval_ms = mero_conf:pool_min_connection_interval(ClusterName)}.

test/mero_dummy_server.erl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
%%
2929
-module(mero_dummy_server).
3030

31+
%% @todo Remove once https://github.com/inaka/elvis_core/issues/308 is dealt with
32+
-elvis([{elvis_style, export_used_types, disable}]).
33+
3134
-include_lib("mero/include/mero.hrl").
3235

3336
-behaviour(gen_server).

test/mero_test_with_local_memcached_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ mget(Cluster, ClusterAlt, Keys) ->
284284
end,
285285
Keys).
286286

287-
mincrement(Cluster = cluster_txt, Keys) ->
287+
mincrement(cluster_txt = Cluster, Keys) ->
288288
{error, not_supportable} = mero:mincrement_counter(Cluster, Keys);
289-
mincrement(Cluster = cluster_binary, Keys) ->
289+
mincrement(cluster_binary = Cluster, Keys) ->
290290
ok = mero:mincrement_counter(Cluster, Keys),
291291
MGetRet =
292292
lists:sort(

0 commit comments

Comments
 (0)