Skip to content

Commit f61ea57

Browse files
[AUTO] Update Dependencies (#94)
* Update dependencies * [update-deps] Fix Elvis warnings * [update-deps] Use the latest formatter * [update-deps] Fix CI and add 25.0 * [update-deps] Adjust for OTP25 * [update-deps] Adjust for OTP25 * Revert "[update-deps] Adjust for OTP25" This reverts commit 0f9292a. * Revert "[update-deps] Adjust for OTP25" This reverts commit 74839b1. * [update-deps] Just don't do 25 yet Co-authored-by: Brujo Benavides <[email protected]>
1 parent 9dabad1 commit f61ea57

File tree

10 files changed

+108
-86
lines changed

10 files changed

+108
-86
lines changed

.github/workflows/erlang.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,30 @@ jobs:
1313
otp: [23.3, 24.3]
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717
- uses: erlef/setup-beam@v1
18+
id: setup-beam
1819
with:
1920
otp-version: ${{matrix.otp}}
2021
rebar3-version: '3.18.0'
2122
- name: Restore _build
22-
uses: actions/cache@v2
23+
uses: actions/cache@v3
2324
with:
2425
path: _build
25-
key: _build-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}}
26+
key: "_build-cache-for\
27+
-os-${{runner.os}}\
28+
-otp-${{steps.setup-beam.outputs.otp-version}}\
29+
-rebar3-${{steps.setup-beam.outputs.rebar3-version}}\
30+
-hash-${{hashFiles('rebar.lock')}}"
2631
- name: Restore rebar3's cache
27-
uses: actions/cache@v2
32+
uses: actions/cache@v3
2833
with:
2934
path: ~/.cache/rebar3
30-
key: rebar3-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}}
35+
key: "rebar3-cache-for\
36+
-os-${{runner.os}}\
37+
-otp-${{steps.setup-beam.outputs.otp-version}}\
38+
-rebar3-${{steps.setup-beam.outputs.rebar3-version}}\
39+
-hash-${{hashFiles('rebar.lock')}}"
3140
- name: Compile
3241
run: rebar3 compile
3342
- name: Format check

rebar.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929

3030
{project_plugins,
3131
[{rebar3_hex, "~> 7.0.1"},
32-
{rebar3_format, "~> 1.2.0"},
33-
{rebar3_lint, "~> 1.0.2"},
32+
{rebar3_format, "~> 1.2.1"},
33+
{rebar3_lint, "~> 1.1.0"},
3434
{rebar3_hank, "~> 1.3.0"}]}.

src/mero_cluster.erl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,18 @@ get_server_defs({ClusterName, ClusterConfig}) ->
291291
{Elements, _} =
292292
lists:foldl(fun({Host, Port}, {Acc, ShardSizeAcc}) ->
293293
Elements =
294-
[begin
295-
WorkerName =
296-
worker_name(ClusterName, Host, ReplicationNumber, ShardSizeAcc),
297-
{ClusterName,
298-
ShardSizeAcc,
299-
ReplicationNumber,
300-
{ClusterName, Host, Port, WorkerName, WorkerModule}}
301-
end
302-
|| ReplicationNumber <- lists:seq(0, Workers - 1)],
294+
lists:map(fun(ReplicationNumber) ->
295+
WorkerName =
296+
worker_name(ClusterName,
297+
Host,
298+
ReplicationNumber,
299+
ShardSizeAcc),
300+
{ClusterName,
301+
ShardSizeAcc,
302+
ReplicationNumber,
303+
{ClusterName, Host, Port, WorkerName, WorkerModule}}
304+
end,
305+
lists:seq(0, Workers - 1)),
303306
{Acc ++ Elements, ShardSizeAcc + 1}
304307
end,
305308
{[], 0},

src/mero_conn.erl

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,22 @@ async_by_shard(Name,
217217
response_error = AsyncOpResponseError}) ->
218218
{Processed, Errors} =
219219
lists:foldl(fun({ShardIdentifier, Items}, {Processed, Errors}) ->
220-
begin
221-
PoolName = mero_cluster:random_pool_of_shard(Name, ShardIdentifier),
222-
case mero_pool:checkout(PoolName, TimeLimit) of
223-
{ok, Conn} ->
224-
case mero_pool:transaction(Conn, AsyncOp, [Items]) of
225-
{error, Reason} ->
226-
mero_pool:close(Conn, AsyncOpError),
227-
mero_pool:checkin_closed(Conn),
228-
{Processed, [Reason | Errors]};
229-
{NConn, {error, Reason}} ->
230-
mero_pool:checkin(NConn),
231-
{Processed, [Reason | Errors]};
232-
{NConn, ok} ->
233-
{[{NConn, Items} | Processed], Errors}
234-
end;
235-
{error, Reason} ->
236-
{Processed, [Reason | Errors]}
237-
end
220+
PoolName = mero_cluster:random_pool_of_shard(Name, ShardIdentifier),
221+
case mero_pool:checkout(PoolName, TimeLimit) of
222+
{ok, Conn} ->
223+
case mero_pool:transaction(Conn, AsyncOp, [Items]) of
224+
{error, Reason} ->
225+
mero_pool:close(Conn, AsyncOpError),
226+
mero_pool:checkin_closed(Conn),
227+
{Processed, [Reason | Errors]};
228+
{NConn, {error, Reason}} ->
229+
mero_pool:checkin(NConn),
230+
{Processed, [Reason | Errors]};
231+
{NConn, ok} ->
232+
{[{NConn, Items} | Processed], Errors}
233+
end;
234+
{error, Reason} ->
235+
{Processed, [Reason | Errors]}
238236
end
239237
end,
240238
{[], []},

src/mero_elasticache.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ parse_cluster_entries([H | T], Accum) ->
125125
[Host, IP, Port] ->
126126
case inet:parse_ipv4_address(IP) of
127127
{ok, IPAddr} ->
128-
case catch erlang:list_to_integer(Port) of
129-
{'EXIT', _} ->
130-
{error, bad_port};
128+
try erlang:list_to_integer(Port) of
131129
P when P < 1 orelse P > 65535 ->
132130
{error, bad_port};
133131
P ->
134132
parse_cluster_entries(T, [{Host, IPAddr, P} | Accum])
133+
catch
134+
_:_ ->
135+
{error, bad_port}
135136
end;
136137
{error, _} ->
137138
{error, bad_ip}

src/mero_pool.erl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
-author('Miriam Pena <[email protected]>').
3232

33+
%% catch X is used as a way to fire and forget, ignoring errors if there are any
34+
-elvis([{elvis_style, no_catch_expressions, disable}]).
35+
3336
%% many functions are "callbacks" for proc_lib
3437
-hank([{unnecessary_function_arguments, [system_terminate]}]).
3538

src/mero_wrk_tcp_binary.erl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
-author('Miriam Pena <[email protected]>').
3232

33+
%% The usage of throw here is intentional and it's correctly used for non-local returns.
34+
-elvis([{elvis_style, no_throw, disable}]).
35+
3336
-include_lib("mero/include/mero.hrl").
3437

3538
-behaviour(mero_pool).

src/mero_wrk_tcp_txt.erl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
-author('Miriam Pena <[email protected]>').
3232

33+
%% The usage of throw here is intentional and it's correctly used for non-local returns.
34+
-elvis([{elvis_style, no_throw, disable}]).
35+
3336
-include_lib("mero/include/mero.hrl").
3437

3538
-behaviour(mero_pool).

test/mero_cluster_SUITE.erl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,21 @@ load_cluster(_Conf) ->
128128
ok.
129129

130130
shard_phash2(_Conf) ->
131-
[[begin
132-
Result = mero:shard_phash2(Key, Shards),
133-
?assertEqual(Result, mero:shard_phash2(Key, Shards)),
134-
?assert(Result =< Shards)
135-
end
136-
|| Shards <- lists:seq(1, 10)]
131+
[lists:map(fun(Shards) ->
132+
Result = mero:shard_phash2(Key, Shards),
133+
?assertEqual(Result, mero:shard_phash2(Key, Shards)),
134+
?assert(Result =< Shards)
135+
end,
136+
lists:seq(1, 10))
137137
|| Key <- [<<"Adroll">>, <<"retargetting">>, <<"platform">>]].
138138

139139
shard_crc32(_Conf) ->
140-
[[begin
141-
Result = mero:shard_crc32(Key, Shards),
142-
?assertEqual(Result, mero:shard_crc32(Key, Shards)),
143-
?assert(Result =< Shards)
144-
end
145-
|| Shards <- lists:seq(1, 10)]
140+
[lists:map(fun(Shards) ->
141+
Result = mero:shard_crc32(Key, Shards),
142+
?assertEqual(Result, mero:shard_crc32(Key, Shards)),
143+
?assert(Result =< Shards)
144+
end,
145+
lists:seq(1, 10))
146146
|| Key <- [<<"Adroll">>, <<"retargetting">>, <<"platform">>]].
147147

148148
select_pool(_Conf) ->

test/mero_test_with_local_memcached_SUITE.erl

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@ mget(Cluster, ClusterAlt, Keys) ->
280280
Results = mero:mget(Cluster, Keys, 10000),
281281
ResultsAlt = mero:mget(ClusterAlt, Keys, 10000),
282282
io:format("Checking mget ~p ~n", [Results]),
283-
[begin
284-
?assertEqual({value, {Key, Key}}, lists:keysearch(Key, 1, Results)),
285-
?assertEqual({value, {Key, Key}}, lists:keysearch(Key, 1, ResultsAlt))
286-
end
287-
|| Key <- Keys].
283+
lists:foreach(fun(Key) ->
284+
?assertEqual({value, {Key, Key}}, lists:keysearch(Key, 1, Results)),
285+
?assertEqual({value, {Key, Key}}, lists:keysearch(Key, 1, ResultsAlt))
286+
end,
287+
Keys).
288288

289289
mincrement(Cluster = cluster_txt, Keys) ->
290290
{error, not_supportable} = mero:mincrement_counter(Cluster, Keys);
@@ -337,43 +337,45 @@ add(Cluster, ClusterAlt, Keys) ->
337337
io:format("Attempt to add success to 5000 ~n"),
338338
Expected = <<"5000">>,
339339
Expected2 = <<"asdf">>,
340-
[begin
341-
?assertEqual(ok, mero:add(Cluster, Key, Expected, 10000, 10000)),
342-
?assertEqual({error, not_stored}, mero:add(cluster_txt, Key, Expected2, 10000, 10000)),
343-
?assertEqual({error, already_exists},
344-
mero:add(cluster_binary, Key, Expected2, 10000, 10000)),
345-
{Key, Value} = mero:get(Cluster, Key),
346-
{Key, Value2} = mero:get(ClusterAlt, Key),
347-
io:format("Checking get ~p ~p ~n", [Value, Value2]),
348-
?assertEqual(Expected, Value),
349-
?assertEqual(Expected, Value2)
350-
end
351-
|| Key <- Keys].
340+
lists:foreach(fun(Key) ->
341+
?assertEqual(ok, mero:add(Cluster, Key, Expected, 10000, 10000)),
342+
?assertEqual({error, not_stored},
343+
mero:add(cluster_txt, Key, Expected2, 10000, 10000)),
344+
?assertEqual({error, already_exists},
345+
mero:add(cluster_binary, Key, Expected2, 10000, 10000)),
346+
{Key, Value} = mero:get(Cluster, Key),
347+
{Key, Value2} = mero:get(ClusterAlt, Key),
348+
io:format("Checking get ~p ~p ~n", [Value, Value2]),
349+
?assertEqual(Expected, Value),
350+
?assertEqual(Expected, Value2)
351+
end,
352+
Keys).
352353

353354
cas(Cluster, ClusterAlt, Keys) ->
354355
Value1 = <<"asdf">>,
355356
Value2 = <<"foo">>,
356357
Value3 = <<"bar">>,
357-
[begin
358-
?assertEqual({error, not_found}, mero:cas(Cluster, Key, Value1, 10000, 10000, 12345)),
359-
await_connected(Cluster),
360-
?assertEqual(ok, mero:set(Cluster, Key, Value1, 10000, 10000)),
361-
?assertEqual({Key, Value1}, mero:get(ClusterAlt, Key)),
362-
{Key, Value1, CAS} = mero:gets(Cluster, Key),
363-
{Key, Value1, CAS} = mero:gets(ClusterAlt, Key),
364-
?assertEqual({error, already_exists},
365-
mero:cas(Cluster, Key, Value2, 10000, 10000, CAS + 1)),
366-
await_connected(Cluster),
367-
?assertEqual(ok, mero:cas(Cluster, Key, Value2, 10000, 10000, CAS)),
368-
?assertEqual({error, already_exists},
369-
mero:cas(ClusterAlt, Key, Value2, 10000, 10000, CAS)),
370-
await_connected(ClusterAlt),
371-
?assertEqual({Key, Value2}, mero:get(ClusterAlt, Key)),
372-
?assertEqual(ok, mero:set(Cluster, Key, Value3, 10000, 10000)),
373-
{Key, Value3, NCAS} = mero:gets(Cluster, Key),
374-
?assertNotEqual(CAS, NCAS)
375-
end
376-
|| Key <- Keys].
358+
lists:foreach(fun(Key) ->
359+
?assertEqual({error, not_found},
360+
mero:cas(Cluster, Key, Value1, 10000, 10000, 12345)),
361+
await_connected(Cluster),
362+
?assertEqual(ok, mero:set(Cluster, Key, Value1, 10000, 10000)),
363+
?assertEqual({Key, Value1}, mero:get(ClusterAlt, Key)),
364+
{Key, Value1, CAS} = mero:gets(Cluster, Key),
365+
{Key, Value1, CAS} = mero:gets(ClusterAlt, Key),
366+
?assertEqual({error, already_exists},
367+
mero:cas(Cluster, Key, Value2, 10000, 10000, CAS + 1)),
368+
await_connected(Cluster),
369+
?assertEqual(ok, mero:cas(Cluster, Key, Value2, 10000, 10000, CAS)),
370+
?assertEqual({error, already_exists},
371+
mero:cas(ClusterAlt, Key, Value2, 10000, 10000, CAS)),
372+
await_connected(ClusterAlt),
373+
?assertEqual({Key, Value2}, mero:get(ClusterAlt, Key)),
374+
?assertEqual(ok, mero:set(Cluster, Key, Value3, 10000, 10000)),
375+
{Key, Value3, NCAS} = mero:gets(Cluster, Key),
376+
?assertNotEqual(CAS, NCAS)
377+
end,
378+
Keys).
377379

378380
%% this is needed b/c our test server doesn't emulate a real memcached server with 100%
379381
%% accuracy.

0 commit comments

Comments
 (0)