Skip to content

Commit bcf48f3

Browse files
authored
TECH-76: Upgrades to Erlang/OTP 27 (#35)
* TECH-76: Upgrades to Erlang/OTP 27 * Bumps deps
1 parent a6f63ea commit bcf48f3

17 files changed

+99
-67
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SERVICE_NAME=limiter
2-
OTP_VERSION=24.3.4
3-
REBAR_VERSION=3.18
2+
OTP_VERSION=27.1.2
3+
REBAR_VERSION=3.24
44
THRIFT_VERSION=0.14.2.3

.github/workflows/erlang-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
thrift-version: ${{ steps.thrift-version.outputs.version }}
1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222
- run: grep -v '^#' .env >> $GITHUB_ENV
2323
- id: otp-version
2424
run: echo "::set-output name=version::$OTP_VERSION"
@@ -30,7 +30,7 @@ jobs:
3030
run:
3131
name: Run checks
3232
needs: setup
33-
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.15
33+
uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.17
3434
with:
3535
otp-version: ${{ needs.setup.outputs.otp-version }}
3636
rebar-version: ${{ needs.setup.outputs.rebar-version }}

apps/limiter/src/lim_body.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ apply_op_behaviour(Operation, Body, #{op_behaviour := ComputationConfig}) ->
4747
apply_op_behaviour(_Operation, Body, _Config) ->
4848
Body.
4949

50-
invert_body(Cash = #{amount := Amount}) ->
50+
invert_body(#{amount := Amount} = Cash) ->
5151
Cash#{amount := -Amount}.

apps/limiter/src/lim_client_woody.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ get_service_client_config(ServiceName) ->
3232
ServiceClients = genlib_app:env(?APP, service_clients, #{}),
3333
maps:get(ServiceName, ServiceClients, #{}).
3434

35-
-spec get_service_client_url(atom()) -> lim_maybe:maybe(woody:url()).
35+
-spec get_service_client_url(atom()) -> lim_maybe:'maybe'(woody:url()).
3636
get_service_client_url(ServiceName) ->
3737
maps:get(url, get_service_client_config(ServiceName), undefined).
3838

apps/limiter/src/lim_config_machine.erl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ created_at(#{created_at := CreatedAt}) ->
200200
id(#{id := ID}) ->
201201
ID.
202202

203-
-spec description(config()) -> lim_maybe:maybe(description()).
203+
-spec description(config()) -> lim_maybe:'maybe'(description()).
204204
description(#{description := ID}) ->
205205
ID;
206206
description(_) ->
@@ -238,7 +238,7 @@ scope(_) ->
238238
context_type(#{context_type := Value}) ->
239239
Value.
240240

241-
-spec op_behaviour(config()) -> lim_maybe:maybe(op_behaviour()).
241+
-spec op_behaviour(config()) -> lim_maybe:'maybe'(op_behaviour()).
242242
op_behaviour(#{op_behaviour := Value}) ->
243243
Value;
244244
op_behaviour(_) ->
@@ -281,21 +281,21 @@ get_limit(ID, Version, LimitContext) ->
281281
end).
282282

283283
-spec hold(lim_change(), lim_context()) -> ok | {error, config_error() | {processor(), hold_error()}}.
284-
hold(LimitChange = #limiter_LimitChange{id = ID, version = Version}, LimitContext) ->
284+
hold(#limiter_LimitChange{id = ID, version = Version} = LimitChange, LimitContext) ->
285285
do(fun() ->
286286
{Handler, Config} = unwrap(get_handler(ID, Version, LimitContext)),
287287
unwrap(Handler, Handler:hold(LimitChange, Config, LimitContext))
288288
end).
289289

290290
-spec commit(lim_change(), lim_context()) -> ok | {error, config_error() | {processor(), commit_error()}}.
291-
commit(LimitChange = #limiter_LimitChange{id = ID, version = Version}, LimitContext) ->
291+
commit(#limiter_LimitChange{id = ID, version = Version} = LimitChange, LimitContext) ->
292292
do(fun() ->
293293
{Handler, Config} = unwrap(get_handler(ID, Version, LimitContext)),
294294
unwrap(Handler, Handler:commit(LimitChange, Config, LimitContext))
295295
end).
296296

297297
-spec rollback(lim_change(), lim_context()) -> ok | {error, config_error() | {processor(), rollback_error()}}.
298-
rollback(LimitChange = #limiter_LimitChange{id = ID, version = Version}, LimitContext) ->
298+
rollback(#limiter_LimitChange{id = ID, version = Version} = LimitChange, LimitContext) ->
299299
do(fun() ->
300300
{Handler, Config} = unwrap(get_handler(ID, Version, LimitContext)),
301301
unwrap(Handler, Handler:rollback(LimitChange, Config, LimitContext))
@@ -836,11 +836,11 @@ not_implemented(What) ->
836836

837837
%%
838838

839-
-spec apply_event(machinery:event(timestamped_event(event())), lim_maybe:maybe(config())) -> config().
839+
-spec apply_event(machinery:event(timestamped_event(event())), lim_maybe:'maybe'(config())) -> config().
840840
apply_event({_ID, _Ts, {ev, _EvTs, Event}}, Config) ->
841841
apply_event_(Event, Config).
842842

843-
-spec apply_event_(event(), lim_maybe:maybe(config())) -> config().
843+
-spec apply_event_(event(), lim_maybe:'maybe'(config())) -> config().
844844
apply_event_({created, Config}, undefined) ->
845845
Config.
846846

apps/limiter/src/lim_maybe.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
-module(lim_maybe).
66

7-
-type maybe(T) ::
7+
-type 'maybe'(T) ::
88
undefined | T.
99

10-
-export_type([maybe/1]).
10+
-export_type(['maybe'/1]).
1111

1212
-export([from_result/1]).
1313
-export([to_list/1]).
@@ -18,13 +18,13 @@
1818

1919
%%
2020

21-
-spec from_result({ok, T} | {error, _}) -> maybe(T).
21+
-spec from_result({ok, T} | {error, _}) -> 'maybe'(T).
2222
from_result({ok, T}) ->
2323
T;
2424
from_result({error, _}) ->
2525
undefined.
2626

27-
-spec to_list(maybe(T)) -> [T].
27+
-spec to_list('maybe'(T)) -> [T].
2828
to_list(undefined) ->
2929
[];
3030
to_list(T) ->
@@ -40,14 +40,14 @@ apply(Fun, Arg, _Default) when Arg =/= undefined ->
4040
apply(_Fun, undefined, Default) ->
4141
Default.
4242

43-
-spec get_defined([maybe(T)]) -> T.
43+
-spec get_defined(['maybe'(T)]) -> T.
4444
get_defined([]) ->
4545
erlang:error(badarg);
4646
get_defined([Value | _Tail]) when Value =/= undefined ->
4747
Value;
4848
get_defined([undefined | Tail]) ->
4949
get_defined(Tail).
5050

51-
-spec get_defined(maybe(T), maybe(T)) -> T.
51+
-spec get_defined('maybe'(T), 'maybe'(T)) -> T.
5252
get_defined(V1, V2) ->
5353
get_defined([V1, V2]).

apps/limiter/src/lim_payproc_context.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ get_operation(#context_payproc_Context{op = undefined}) ->
3333
make_change_context(#context_payproc_Context{op = undefined}) ->
3434
{ok, #{}};
3535
make_change_context(
36-
Context = #context_payproc_Context{
36+
#context_payproc_Context{
3737
op = {Operation, _}
38-
}
38+
} = Context
3939
) ->
4040
{ok,
4141
genlib_map:compact(#{

apps/limiter/src/lim_posting.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ new(#{account_id_from := From, account_id_to := To}, Amount, Currency) ->
1818
description = <<>>
1919
}).
2020

21-
reverse_negative_posting(Posting = #accounter_Posting{amount = Amount}) when Amount < 0 ->
21+
reverse_negative_posting(#accounter_Posting{amount = Amount} = Posting) when Amount < 0 ->
2222
PostingReversed = reverse(Posting),
2323
PostingReversed#accounter_Posting{amount = -Amount};
2424
reverse_negative_posting(Posting) ->
2525
Posting.
2626

2727
-spec reverse(posting()) -> posting().
28-
reverse(Posting = #accounter_Posting{from_id = AccountFrom, to_id = AccountTo}) ->
28+
reverse(#accounter_Posting{from_id = AccountFrom, to_id = AccountTo} = Posting) ->
2929
Posting#accounter_Posting{
3030
from_id = AccountTo,
3131
to_id = AccountFrom

apps/limiter/src/lim_range_codec.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ marshal(change, {time_range_created, TimeRange}) ->
3131
{time_range_created, #range_TimeRangeCreatedChange{time_range = marshal(time_range, TimeRange)}};
3232
marshal(
3333
range,
34-
Range = #{
34+
#{
3535
id := ID,
3636
type := Type,
3737
created_at := CreatedAt
38-
}
38+
} = Range
3939
) ->
4040
#range_LimitRange{
4141
id = ID,

apps/limiter/src/lim_range_machine.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ get(ID, LimitContext) ->
123123
get_state(ID, lim_context:woody_context(LimitContext)).
124124

125125
-spec ensure_exists(create_params(), time_range(), lim_context()) -> {ok, time_range_ext()}.
126-
ensure_exists(Params = #{id := ID}, TimeRange, LimitContext) ->
126+
ensure_exists(#{id := ID} = Params, TimeRange, LimitContext) ->
127127
WoodyCtx = lim_context:woody_context(LimitContext),
128128
case get_state(ID, WoodyCtx) of
129129
{ok, State} ->
@@ -246,15 +246,15 @@ not_implemented(What) ->
246246

247247
%%
248248

249-
-spec apply_event(machinery:event(timestamped_event(event())), lim_maybe:maybe(limit_range_state())) ->
249+
-spec apply_event(machinery:event(timestamped_event(event())), lim_maybe:'maybe'(limit_range_state())) ->
250250
limit_range_state().
251251
apply_event({_ID, _Ts, {ev, _EvTs, Event}}, Config) ->
252252
apply_event_(Event, Config).
253253

254-
-spec apply_event_(event(), lim_maybe:maybe(limit_range_state())) -> limit_range_state().
254+
-spec apply_event_(event(), lim_maybe:'maybe'(limit_range_state())) -> limit_range_state().
255255
apply_event_({created, LimitRange}, undefined) ->
256256
LimitRange;
257-
apply_event_({time_range_created, TimeRange}, LimitRange = #{ranges := Ranges}) ->
257+
apply_event_({time_range_created, TimeRange}, #{ranges := Ranges} = LimitRange) ->
258258
LimitRange#{ranges => [TimeRange | Ranges]};
259259
apply_event_({time_range_created, TimeRange}, LimitRange) ->
260260
LimitRange#{ranges => [TimeRange]}.

0 commit comments

Comments
 (0)