Skip to content
Merged
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: 0 additions & 4 deletions apps/limiter/src/lim_config_codec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ marshal_scope_type(shop) ->
{shop, #config_LimitScopeEmptyDetails{}};
marshal_scope_type(wallet) ->
{wallet, #config_LimitScopeEmptyDetails{}};
marshal_scope_type(identity) ->
{identity, #config_LimitScopeEmptyDetails{}};
marshal_scope_type(payment_tool) ->
{payment_tool, #config_LimitScopeEmptyDetails{}};
marshal_scope_type(provider) ->
Expand Down Expand Up @@ -346,8 +344,6 @@ unmarshal_scope_type({shop, _}) ->
shop;
unmarshal_scope_type({wallet, _}) ->
wallet;
unmarshal_scope_type({identity, _}) ->
identity;
unmarshal_scope_type({payment_tool, _}) ->
payment_tool;
unmarshal_scope_type({provider, _}) ->
Expand Down
23 changes: 9 additions & 14 deletions apps/limiter/src/lim_config_machine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
party
| shop
| wallet
| identity
| payment_tool
| provider
| terminal
Expand Down Expand Up @@ -675,7 +674,6 @@ enumerate_context_bits(Types) ->
[
party,
shop,
identity,
wallet,
payment_tool,
provider,
Expand Down Expand Up @@ -707,13 +705,13 @@ squash_scope_types([party, shop | Rest]) ->
% NOTE
% Shop scope implies party scope.
[shop | squash_scope_types(Rest)];
squash_scope_types([identity, wallet | Rest]) ->
squash_scope_types([party, wallet | Rest]) ->
% NOTE
% Wallet scope implies identity scope.
% Wallet scope implies party scope.
[wallet | squash_scope_types(Rest)];
squash_scope_types([provider, terminal | Rest]) ->
% NOTE
% Provider scope implies identity scope.
% Provider scope implies provider scope.
[terminal | squash_scope_types(Rest)];
squash_scope_types([Type | Rest]) ->
[Type | squash_scope_types(Rest)];
Expand All @@ -729,10 +727,8 @@ get_context_bits(shop) ->
[{from, owner_id}, {from, shop_id}];
get_context_bits(payment_tool) ->
[{from, payment_tool}];
get_context_bits(identity) ->
[{prefix, <<"identity">>}, {from, identity_id}];
get_context_bits(wallet) ->
[{prefix, <<"wallet">>}, {from, identity_id}, {from, wallet_id}];
[{prefix, <<"wallet">>}, {from, owner_id}, {from, wallet_id}];
get_context_bits(provider) ->
[{prefix, <<"provider">>}, {from, provider_id}];
get_context_bits(terminal) ->
Expand Down Expand Up @@ -1066,9 +1062,9 @@ check_calculate_year_shard_id_test() ->
}
}).

-define(WITHDRAWAL(OwnerID, IdentityID, PaymentTool), #wthd_domain_Withdrawal{
-define(WITHDRAWAL(OwnerID, PaymentTool), #wthd_domain_Withdrawal{
destination = PaymentTool,
sender = #wthd_domain_Identity{id = IdentityID, owner_id = OwnerID},
sender = OwnerID,
created_at = <<"2000-02-02T12:12:12Z">>,
body = #domain_Cash{amount = 42, currency = #domain_CurrencyRef{symbolic_code = <<"CNY">>}}
}).
Expand Down Expand Up @@ -1112,7 +1108,7 @@ prefix_content_test_() ->
},
WithdrawalContext = #{
context => ?WITHDRAWAL_CTX(
?WITHDRAWAL(<<"OWNER">>, <<"IDENTITY">>, ?PAYMENT_TOOL),
?WITHDRAWAL(<<"OWNER">>, ?PAYMENT_TOOL),
<<"WALLET">>,
?ROUTE(22, 2)
)
Expand All @@ -1138,13 +1134,12 @@ prefix_content_test_() ->
),
?_assertEqual(
{ok,
{<<"/OWNER/wallet/IDENTITY/WALLET">>, #{
<<"Scope.identity_id">> => <<"IDENTITY">>,
{<<"/wallet/OWNER/WALLET">>, #{
<<"Scope.owner_id">> => <<"OWNER">>,
<<"Scope.prefix">> => <<"wallet">>,
<<"Scope.wallet_id">> => <<"WALLET">>
}}},
mk_scope_prefix_impl(ordsets:from_list([wallet, identity, party]), withdrawal_processing, WithdrawalContext)
mk_scope_prefix_impl(ordsets:from_list([wallet, party]), withdrawal_processing, WithdrawalContext)
),
?_assertEqual(
{ok,
Expand Down
12 changes: 1 addition & 11 deletions apps/limiter/src/lim_wthdproc_context.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ make_change_context(
genlib_map:compact(#{
<<"Context.op">> => genlib:to_binary(Operation),
<<"Context.owner_id">> => try_get_value(owner_id, Context, undefined),
<<"Context.identity_id">> => try_get_value(identity_id, Context, undefined),
<<"Context.wallet_id">> => try_get_value(wallet_id, Context, undefined)
})}.

Expand Down Expand Up @@ -71,8 +70,6 @@ get_value(cost, Operation, Context) ->
get_cost(Operation, Context);
get_value(payment_tool, Operation, Context) ->
get_payment_tool(Operation, Context);
get_value(identity_id, Operation, Context) ->
get_identity_id(Operation, Context);
get_value(wallet_id, Operation, Context) ->
get_wallet_id(Operation, Context);
get_value(provider_id, Operation, Context) ->
Expand Down Expand Up @@ -113,8 +110,7 @@ get_value(ValueName, _Operation, _Context) ->
-define(SENDER_RECEIVER(V), ?AUTH_DATA({sender_receiver, V})).

get_owner_id(?WITHDRAWAL(Wthd)) ->
Identity = Wthd#wthd_domain_Withdrawal.sender,
{ok, Identity#wthd_domain_Identity.owner_id};
{ok, Wthd#wthd_domain_Withdrawal.sender};
get_owner_id(_CtxWithdrawal) ->
{error, notfound}.

Expand All @@ -135,12 +131,6 @@ get_payment_tool(withdrawal, ?WITHDRAWAL(Wthd)) ->
get_payment_tool(_, _CtxWithdrawal) ->
{error, notfound}.

get_identity_id(withdrawal, ?WITHDRAWAL(Wthd)) ->
Identity = Wthd#wthd_domain_Withdrawal.sender,
{ok, Identity#wthd_domain_Identity.id};
get_identity_id(_, _CtxWithdrawal) ->
{error, notfound}.

get_wallet_id(withdrawal, ?WALLET_ID(WalletID)) ->
{ok, WalletID};
get_wallet_id(_, _CtxWithdrawal) ->
Expand Down
8 changes: 1 addition & 7 deletions apps/limiter/test/lim_ct_helper.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
-define(scope_provider(), {provider, #config_LimitScopeEmptyDetails{}}).
-define(scope_terminal(), {terminal, #config_LimitScopeEmptyDetails{}}).
-define(scope_payer_contact_email(), {payer_contact_email, #config_LimitScopeEmptyDetails{}}).
-define(scope_identity(), {identity, #config_LimitScopeEmptyDetails{}}).
-define(scope_wallet(), {wallet, #config_LimitScopeEmptyDetails{}}).
-define(scope_sender(), {sender, #config_LimitScopeEmptyDetails{}}).
-define(scope_receiver(), {receiver, #config_LimitScopeEmptyDetails{}}).
Expand Down Expand Up @@ -231,11 +230,6 @@

%% Wthdproc

-define(identity(OwnerID), #wthd_domain_Identity{
id = OwnerID,
owner_id = OwnerID
}).

-define(auth_data(Sender, Receiver),
{sender_receiver, #wthd_domain_SenderReceiverAuthData{sender = Sender, receiver = Receiver}}
).
Expand All @@ -248,7 +242,7 @@
body = Body,
created_at = ?timestamp,
destination = Destination,
sender = ?identity(OwnerID),
sender = OwnerID,
auth_data = AuthData
}).

Expand Down
11 changes: 1 addition & 10 deletions apps/limiter/test/lim_turnover_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
-export([commit_with_terminal_scope_ok/1]).
-export([commit_with_email_scope_ok/1]).

-export([commit_with_identity_scope_ok/1]).
-export([commit_with_wallet_scope_ok/1]).
-export([commit_with_multi_scope_ok/1]).
-export([hold_with_sender_notfound/1]).
Expand Down Expand Up @@ -156,7 +155,6 @@ groups() ->
commit_with_party_scope_ok,
commit_with_provider_scope_ok,
commit_with_terminal_scope_ok,
commit_with_identity_scope_ok,
commit_with_wallet_scope_ok,
commit_with_sender_scope_ok,
commit_with_receiver_scope_ok,
Expand Down Expand Up @@ -714,16 +712,9 @@ commit_with_email_scope_ok(C) ->
{ok, {vector, _}} = hold_and_commit(?LIMIT_CHANGE(ID, ?CHANGE_ID, Version), Context, ?config(client, C)),
{ok, #limiter_Limit{}} = lim_client:get(ID, Version, Context, ?config(client, C)).

-spec commit_with_identity_scope_ok(config()) -> _.
commit_with_identity_scope_ok(C) ->
{ID, Version} = configure_limit(?time_range_month(), ?scope([?scope_identity()]), C),
Context = ?wthdproc_ctx_withdrawal(?cash(10, <<"RUB">>)),
{ok, {vector, _}} = hold_and_commit(?LIMIT_CHANGE(ID, ?CHANGE_ID, Version), Context, ?config(client, C)),
{ok, #limiter_Limit{}} = lim_client:get(ID, Version, Context, ?config(client, C)).

-spec commit_with_wallet_scope_ok(config()) -> _.
commit_with_wallet_scope_ok(C) ->
{ID, Version} = configure_limit(?time_range_month(), ?scope([?scope_wallet()]), C),
{ID, Version} = configure_limit(?time_range_month(), ?scope([?scope_party(), ?scope_wallet()]), C),
Context = ?wthdproc_ctx_withdrawal(?cash(10, <<"RUB">>)),
{ok, {vector, _}} = hold_and_commit(?LIMIT_CHANGE(ID, ?CHANGE_ID, Version), Context, ?config(client, C)),
{ok, #limiter_Limit{}} = lim_client:get(ID, Version, Context, ?config(client, C)).
Expand Down
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
condition: service_healthy

dominant:
image: ghcr.io/valitydev/dominant:sha-2150eea
image: ghcr.io/valitydev/dominant:sha-ef03371-epic-party_here
command: /opt/dominant/bin/dominant foreground
depends_on:
machinegun:
Expand Down
4 changes: 1 addition & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@
% for introspection on production
{recon, "2.5.2"},
{logger_logstash_formatter,
{git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}},
{iosetopts, {git, "https://github.com/valitydev/iosetopts.git", {ref, "edb445c"}}}
{git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}}
]},
{relx, [
{release, {limiter, "1.0.0"}, [
iosetopts,
{recon, load},
{runtime_tools, load},
{tools, load},
Expand Down
4 changes: 2 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"81d1edce2043500e4581867da3f5f4c31e682f44"}},
{ref,"ab44b9db25a76a2c50545fd884e4cdf3d3e3b628"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/valitydev/dmt_client.git",
Expand Down Expand Up @@ -59,7 +59,7 @@
0},
{<<"limiter_proto">>,
{git,"https://github.com/valitydev/limiter-proto.git",
{ref,"efeb7d4a05bd13c95fada18514509b34b107fcb9"}},
{ref,"d4cdf0f6328125996ee705c3da87461f99dde7f4"}},
0},
{<<"machinery">>,
{git,"https://github.com/valitydev/machinery-erlang.git",
Expand Down
Loading