Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH-76: Upgrades to Erlang/OTP 27 #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs
# are the same. See: https://github.com/erlware/relx/pull/902
SERVICE_NAME=fistful-server
OTP_VERSION=24.3
REBAR_VERSION=3.18
OTP_VERSION=27.1.2
REBAR_VERSION=3.24
THRIFT_VERSION=0.14.2.3
6 changes: 3 additions & 3 deletions apps/ff_core/src/ff_indef.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ expmin(#{expected_min := V}) ->
expmax(#{expected_max := V}) ->
V.

account(Delta, Indef = #{expected_min := ExpMin, expected_max := ExpMax}) ->
account(Delta, #{expected_min := ExpMin, expected_max := ExpMax} = Indef) ->
Indef#{
expected_min := erlang:min(ExpMin + Delta, ExpMin),
expected_max := erlang:max(ExpMax + Delta, ExpMax)
}.

confirm(Delta, Indef = #{current := Current, expected_min := ExpMin, expected_max := ExpMax}) ->
confirm(Delta, #{current := Current, expected_min := ExpMin, expected_max := ExpMax} = Indef) ->
Indef#{
current := Current + Delta,
expected_min := erlang:max(ExpMin + Delta, ExpMin),
expected_max := erlang:min(ExpMax + Delta, ExpMax)
}.

reject(Delta, Indef = #{expected_min := ExpMin, expected_max := ExpMax}) ->
reject(Delta, #{expected_min := ExpMin, expected_max := ExpMax} = Indef) ->
Indef#{
expected_min := erlang:max(ExpMin - Delta, ExpMin),
expected_max := erlang:min(ExpMax - Delta, ExpMax)
Expand Down
12 changes: 6 additions & 6 deletions apps/ff_core/src/ff_maybe.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

-module(ff_maybe).

-type maybe(T) ::
-type 'maybe'(T) ::
undefined | T.

-export_type([maybe/1]).
-export_type(['maybe'/1]).

-export([from_result/1]).
-export([to_list/1]).
Expand All @@ -18,13 +18,13 @@

%%

-spec from_result({ok, T} | {error, _}) -> maybe(T).
-spec from_result({ok, T} | {error, _}) -> 'maybe'(T).
from_result({ok, T}) ->
T;
from_result({error, _}) ->
undefined.

-spec to_list(maybe(T)) -> [T].
-spec to_list('maybe'(T)) -> [T].
to_list(undefined) ->
[];
to_list(T) ->
Expand All @@ -40,14 +40,14 @@ apply(Fun, Arg, _Default) when Arg =/= undefined ->
apply(_Fun, undefined, Default) ->
Default.

-spec get_defined([maybe(T)]) -> T.
-spec get_defined(['maybe'(T)]) -> T.
get_defined([]) ->
erlang:error(badarg);
get_defined([Value | _Tail]) when Value =/= undefined ->
Value;
get_defined([undefined | Tail]) ->
get_defined(Tail).

-spec get_defined(maybe(T), maybe(T)) -> T.
-spec get_defined('maybe'(T), 'maybe'(T)) -> T.
get_defined(V1, V2) ->
get_defined([V1, V2]).
4 changes: 2 additions & 2 deletions apps/ff_core/src/ff_range.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

-module(ff_range).

-type range(T) :: {maybe(bound(T)), maybe(bound(T))}.
-type range(T) :: {'maybe'(bound(T)), 'maybe'(bound(T))}.
-type bound(T) :: {exclusive | inclusive, ord(T)}.

-type maybe(T) :: infinity | T.
-type 'maybe'(T) :: infinity | T.
% totally ordered
-type ord(T) :: T.

Expand Down
2 changes: 1 addition & 1 deletion apps/ff_cth/src/ct_domain.erl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ term_set_hierarchy(Ref) ->
term_set_hierarchy(Ref, TermSets) ->
term_set_hierarchy(Ref, undefined, TermSets).

-spec term_set_hierarchy(Ref, ff_maybe:maybe(Ref), [?DTP('TimedTermSet')]) -> object() when
-spec term_set_hierarchy(Ref, ff_maybe:'maybe'(Ref), [?DTP('TimedTermSet')]) -> object() when
Ref :: ?DTP('TermSetHierarchyRef').
term_set_hierarchy(Ref, ParentRef, TermSets) ->
{term_set_hierarchy, #domain_TermSetHierarchyObject{
Expand Down
6 changes: 3 additions & 3 deletions apps/ff_cth/src/ct_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

-spec start() -> pid().
start() ->
{ok, PID} = supervisor:start_link(?MODULE, []),
true = unlink(PID),
PID.
{ok, Pid} = supervisor:start_link(?MODULE, []),
true = unlink(Pid),
Pid.

-spec stop(pid()) -> ok.
stop(Pid) ->
Expand Down
15 changes: 7 additions & 8 deletions apps/ff_server/src/ff_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-include_lib("fistful_proto/include/fistful_fistful_base_thrift.hrl").
-include_lib("fistful_proto/include/fistful_repairer_thrift.hrl").
-include_lib("fistful_proto/include/fistful_account_thrift.hrl").
-include_lib("fistful_proto/include/fistful_msgp_thrift.hrl").
-include_lib("fistful_proto/include/fistful_fistful_thrift.hrl").
-include_lib("fistful_proto/include/fistful_evsink_thrift.hrl").

Expand Down Expand Up @@ -79,10 +78,10 @@ marshal(withdrawal_method, #{id := {bank_card, #{payment_system := PaymentSystem
}};
marshal(
transaction_info,
TransactionInfo = #{
#{
id := TransactionID,
extra := Extra
}
} = TransactionInfo
) ->
Timestamp = maps:get(timestamp, TransactionInfo, undefined),
AddInfo = maps:get(additional_info, TransactionInfo, undefined),
Expand All @@ -92,7 +91,7 @@ marshal(
extra = Extra,
additional_info = marshal(additional_transaction_info, AddInfo)
};
marshal(additional_transaction_info, AddInfo = #{}) ->
marshal(additional_transaction_info, #{} = AddInfo) ->
#'fistful_base_AdditionalTransactionInfo'{
rrn = marshal(string, maps:get(rrn, AddInfo, undefined)),
approval_code = marshal(string, maps:get(approval_code, AddInfo, undefined)),
Expand Down Expand Up @@ -152,7 +151,7 @@ marshal(resource_descriptor, {bank_card, BinDataID}) ->
{bank_card, #'fistful_base_ResourceDescriptorBankCard'{
bin_data_id = marshal(msgpack, BinDataID)
}};
marshal(bank_card, BankCard = #{token := Token}) ->
marshal(bank_card, #{token := Token} = BankCard) ->
Bin = maps:get(bin, BankCard, undefined),
PaymentSystem = ff_resource:payment_system(BankCard),
MaskedPan = ff_resource:masked_pan(BankCard),
Expand All @@ -178,21 +177,21 @@ marshal(bank_card_auth_data, {session, #{session_id := ID}}) ->
{session_data, #'fistful_base_SessionAuthData'{
id = marshal(string, ID)
}};
marshal(crypto_wallet, CryptoWallet = #{id := ID, currency := Currency}) ->
marshal(crypto_wallet, #{id := ID, currency := Currency} = CryptoWallet) ->
#'fistful_base_CryptoWallet'{
id = marshal(string, ID),
currency = marshal(crypto_currency, Currency),
tag = maybe_marshal(string, maps:get(tag, CryptoWallet, undefined))
};
marshal(digital_wallet, Wallet = #{id := ID, payment_service := PaymentService}) ->
marshal(digital_wallet, #{id := ID, payment_service := PaymentService} = Wallet) ->
#'fistful_base_DigitalWallet'{
id = marshal(string, ID),
token = maybe_marshal(string, maps:get(token, Wallet, undefined)),
payment_service = marshal(payment_service, PaymentService),
account_name = maybe_marshal(string, maps:get(account_name, Wallet, undefined)),
account_identity_number = maybe_marshal(string, maps:get(account_identity_number, Wallet, undefined))
};
marshal(generic_resource, Generic = #{provider := PaymentService}) ->
marshal(generic_resource, #{provider := PaymentService} = Generic) ->
#'fistful_base_ResourceGenericData'{
provider = marshal(payment_service, PaymentService),
data = maybe_marshal(content, maps:get(data, Generic, undefined))
Expand Down
4 changes: 2 additions & 2 deletions apps/ff_server/src/ff_deposit_adjustment_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ marshal(changes_plan, Plan) ->
new_status = maybe_marshal(status_change_plan, maps:get(new_status, Plan, undefined))
};
marshal(cash_flow_change_plan, Plan) ->
OldCashFLow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
OldCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
NewCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(new_cash_flow, Plan)),
#deposit_adj_CashFlowChangePlan{
old_cash_flow_inverted = OldCashFLow,
old_cash_flow_inverted = OldCashFlow,
new_cash_flow = NewCashFlow
};
marshal(status_change_plan, Plan) ->
Expand Down
7 changes: 2 additions & 5 deletions apps/ff_server/src/ff_deposit_machinery_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
%% Storage schema behaviour
-behaviour(machinery_mg_schema).

-include_lib("fistful_proto/include/fistful_deposit_thrift.hrl").
-include_lib("mg_proto/include/mg_proto_state_processing_thrift.hrl").

-export([get_version/1]).
-export([marshal/3]).
-export([unmarshal/3]).
Expand Down Expand Up @@ -92,9 +89,9 @@ unmarshal_event(undefined = Version, EncodedChange, Context0) ->
{{ev, Timestamp, maybe_migrate(Change, Context1)}, Context1}.

-spec maybe_migrate(any(), context()) -> ff_deposit:event().
maybe_migrate(Ev = {status_changed, {failed, #{code := _}}}, _MigrateParams) ->
maybe_migrate({status_changed, {failed, #{code := _}}} = Ev, _MigrateParams) ->
Ev;
maybe_migrate(Ev = {limit_check, {wallet_receiver, _Details}}, _MigrateParams) ->
maybe_migrate({limit_check, {wallet_receiver, _Details}} = Ev, _MigrateParams) ->
Ev;
maybe_migrate({p_transfer, PEvent}, _MigrateParams) ->
{p_transfer, ff_postings_transfer:maybe_migrate(PEvent, deposit)};
Expand Down
4 changes: 2 additions & 2 deletions apps/ff_server/src/ff_deposit_revert_adjustment_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ marshal(changes_plan, Plan) ->
new_status = maybe_marshal(status_change_plan, maps:get(new_status, Plan, undefined))
};
marshal(cash_flow_change_plan, Plan) ->
OldCashFLow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
OldCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
NewCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(new_cash_flow, Plan)),
#deposit_revert_adj_CashFlowChangePlan{
old_cash_flow_inverted = OldCashFLow,
old_cash_flow_inverted = OldCashFlow,
new_cash_flow = NewCashFlow
};
marshal(status_change_plan, Plan) ->
Expand Down
4 changes: 2 additions & 2 deletions apps/ff_server/src/ff_destination_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ marshal(change, {status_changed, StatusChange}) ->
{status, marshal(status_change, StatusChange)};
marshal(
create_change,
Destination = #{
#{
name := Name,
resource := Resource
}
} = Destination
) ->
#destination_Destination{
name = Name,
Expand Down
3 changes: 1 addition & 2 deletions apps/ff_server/src/ff_identity_machinery_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
-behaviour(machinery_mg_schema).

-include_lib("fistful_proto/include/fistful_identity_thrift.hrl").
-include_lib("mg_proto/include/mg_proto_state_processing_thrift.hrl").

-export([get_version/1]).
-export([marshal/3]).
Expand Down Expand Up @@ -118,7 +117,7 @@ maybe_migrate_thrift_change(Change, _MigrateContext) ->
Change.

-spec maybe_migrate_change(legacy_change(), context()) -> ff_identity:event().
maybe_migrate_change(Event = {created, #{version := 2, name := _}}, _MigrateContext) ->
maybe_migrate_change({created, #{version := 2, name := _}} = Event, _MigrateContext) ->
Event;
maybe_migrate_change({created, Identity = #{version := 2, id := ID}}, MigrateContext) ->
Context = fetch_entity_context(ID, MigrateContext),
Expand Down
2 changes: 1 addition & 1 deletion apps/ff_server/src/ff_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ init([]) ->
-spec enable_health_logging(erl_health:check()) -> erl_health:check().
enable_health_logging(Check) ->
EvHandler = {erl_health_event_handler, []},
maps:map(fun(_, V = {_, _, _}) -> #{runner => V, event_handler => EvHandler} end, Check).
maps:map(fun(_, {_, _, _} = V) -> #{runner => V, event_handler => EvHandler} end, Check).

-spec get_prometheus_routes() -> [{iodata(), module(), _Opts :: any()}].
get_prometheus_routes() ->
Expand Down
4 changes: 2 additions & 2 deletions apps/ff_server/src/ff_source_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ marshal(change, {status_changed, Status}) ->
{status, #source_StatusChange{status = marshal(status, Status)}};
marshal(
source,
Source = #{
#{
name := Name,
resource := Resource
}
} = Source
) ->
#source_Source{
id = marshal(id, ff_source:id(Source)),
Expand Down
4 changes: 2 additions & 2 deletions apps/ff_server/src/ff_w2w_transfer_adjustment_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ marshal(changes_plan, Plan) ->
new_status = maybe_marshal(status_change_plan, maps:get(new_status, Plan, undefined))
};
marshal(cash_flow_change_plan, Plan) ->
OldCashFLow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
OldCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
NewCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(new_cash_flow, Plan)),
#w2w_adj_CashFlowChangePlan{
old_cash_flow_inverted = OldCashFLow,
old_cash_flow_inverted = OldCashFlow,
new_cash_flow = NewCashFlow
};
marshal(status_change_plan, Plan) ->
Expand Down
5 changes: 1 addition & 4 deletions apps/ff_server/src/ff_wallet_machinery_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
%% Storage schema behaviour
-behaviour(machinery_mg_schema).

-include_lib("fistful_proto/include/fistful_wallet_thrift.hrl").
-include_lib("mg_proto/include/mg_proto_state_processing_thrift.hrl").

-export([get_version/1]).
-export([marshal/3]).
-export([unmarshal/3]).
Expand Down Expand Up @@ -90,7 +87,7 @@ unmarshal_event(undefined = Version, EncodedChange, Context0) ->
{{ev, Timestamp, maybe_migrate(Change, Context1)}, Context1}.

-spec maybe_migrate(any(), context()) -> ff_wallet:event().
maybe_migrate(Event = {created, #{version := 2}}, _MigrateContext) ->
maybe_migrate({created, #{version := 2}} = Event, _MigrateContext) ->
Event;
maybe_migrate({created, Wallet = #{version := 1}}, MigrateContext) ->
Context =
Expand Down
4 changes: 2 additions & 2 deletions apps/ff_server/src/ff_withdrawal_adjustment_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ marshal(changes_plan, Plan) ->
new_domain_revision = maybe_marshal(domain_revision_change_plan, maps:get(new_domain_revision, Plan, undefined))
};
marshal(cash_flow_change_plan, Plan) ->
OldCashFLow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
OldCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(old_cash_flow_inverted, Plan)),
NewCashFlow = ff_cash_flow_codec:marshal(final_cash_flow, maps:get(new_cash_flow, Plan)),
#wthd_adj_CashFlowChangePlan{
old_cash_flow_inverted = OldCashFLow,
old_cash_flow_inverted = OldCashFlow,
new_cash_flow = NewCashFlow
};
marshal(status_change_plan, Plan) ->
Expand Down
2 changes: 1 addition & 1 deletion apps/ff_server/src/ff_withdrawal_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ unmarshal(validation_result, {personal, Validation}) ->
}};
unmarshal(validation_status, V) when V =:= valid; V =:= invalid ->
V;
unmarshal(withdrawal, Withdrawal = #wthd_Withdrawal{}) ->
unmarshal(withdrawal, #wthd_Withdrawal{} = Withdrawal) ->
ff_withdrawal:gen(#{
id => unmarshal(id, Withdrawal#wthd_Withdrawal.id),
body => unmarshal(cash, Withdrawal#wthd_Withdrawal.body),
Expand Down
4 changes: 1 addition & 3 deletions apps/ff_server/src/ff_withdrawal_machinery_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
%% Storage schema behaviour
-behaviour(machinery_mg_schema).

-include_lib("mg_proto/include/mg_proto_state_processing_thrift.hrl").

-export([get_version/1]).
-export([marshal/3]).
-export([unmarshal/3]).
Expand Down Expand Up @@ -96,7 +94,7 @@ unmarshal_event(undefined = Version, EncodedChange, Context) ->
),
{{ev, Timestamp, maybe_migrate(Change, Context1)}, Context1}.

maybe_migrate(Ev = {created, #{version := 4}}, _MigrateParams) ->
maybe_migrate({created, #{version := 4}} = Ev, _MigrateParams) ->
Ev;
maybe_migrate({route_changed, Route}, _MigrateParams) ->
{route_changed, maybe_migrate_route(Route)};
Expand Down
7 changes: 3 additions & 4 deletions apps/ff_server/src/ff_withdrawal_session_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-behaviour(ff_codec).

-include_lib("fistful_proto/include/fistful_wthd_session_thrift.hrl").
-include_lib("fistful_proto/include/fistful_fistful_base_thrift.hrl").

-export([marshal_state/3]).

Expand Down Expand Up @@ -67,11 +66,11 @@ marshal(session_finished_status, {failed, Failure}) ->
{failed, #wthd_session_SessionFinishedFailed{failure = marshal(failure, Failure)}};
marshal(
withdrawal,
Params = #{
#{
id := WithdrawalID,
resource := Resource,
cash := Cash
}
} = Params
) ->
SenderIdentity = maps:get(sender, Params, undefined),
ReceiverIdentity = maps:get(receiver, Params, undefined),
Expand All @@ -86,7 +85,7 @@ marshal(
session_id = maybe_marshal(id, SessionID),
quote = maybe_marshal(quote, Quote)
};
marshal(identity, Identity = #{id := ID}) ->
marshal(identity, #{id := ID} = Identity) ->
#wthd_session_Identity{
identity_id = marshal(id, ID),
effective_challenge = maybe_marshal(challenge, maps:get(effective_challenge, Identity, undefined))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
%% Storage schema behaviour
-behaviour(machinery_mg_schema).

-include_lib("fistful_proto/include/fistful_wthd_session_thrift.hrl").
-include_lib("mg_proto/include/mg_proto_state_processing_thrift.hrl").

-export([get_version/1]).
-export([marshal/3]).
-export([unmarshal/3]).
Expand Down Expand Up @@ -98,7 +95,7 @@ unmarshal_aux_state(undefined = Version, EncodedAuxState, Context0) ->
{maybe_migrate_aux_state(AuxState, Context0), Context1}.

-spec maybe_migrate(any(), context()) -> ff_withdrawal_session:event().
maybe_migrate(Event = {created, #{version := 5}}, _Context) ->
maybe_migrate({created, #{version := 5}} = Event, _Context) ->
Event;
maybe_migrate(
{created,
Expand Down
Loading
Loading