mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 02:45:20 +00:00
TD-675: Adds limit change log notice (#86)
This commit is contained in:
parent
2698128ac0
commit
afcb01738a
@ -116,14 +116,18 @@ commit_payment_limits(TurnoverLimits, Route, Iter, Invoice, Payment, CapturedCas
|
||||
],
|
||||
LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs),
|
||||
Context = gen_limit_context(Invoice, Payment, Route, CapturedCash),
|
||||
commit(LimitChanges, get_latest_clock(), Context).
|
||||
Clock = get_latest_clock(),
|
||||
ok = commit(LimitChanges, Clock, Context),
|
||||
ok = log_limit_changes(TurnoverLimits, Clock, Context).
|
||||
|
||||
-spec commit_refund_limits([turnover_limit()], invoice(), payment(), refund(), route()) -> ok.
|
||||
commit_refund_limits(TurnoverLimits, Invoice, Payment, Refund, Route) ->
|
||||
ChangeIDs = [construct_refund_change_id(Invoice, Payment, Refund)],
|
||||
LimitChanges = gen_limit_changes(TurnoverLimits, ChangeIDs),
|
||||
Context = gen_limit_refund_context(Invoice, Payment, Refund, Route),
|
||||
commit(LimitChanges, get_latest_clock(), Context).
|
||||
Clock = get_latest_clock(),
|
||||
ok = commit(LimitChanges, Clock, Context),
|
||||
ok = log_limit_changes(TurnoverLimits, Clock, Context).
|
||||
|
||||
-spec rollback_payment_limits([turnover_limit()], route(), pos_integer(), invoice(), payment(), [handling_flag()]) ->
|
||||
ok.
|
||||
@ -285,3 +289,51 @@ convert_to_limit_route(#domain_PaymentRoute{provider = Provider, terminal = Term
|
||||
provider = Provider,
|
||||
terminal = Terminal
|
||||
}.
|
||||
|
||||
log_limit_changes(TurnoverLimits, Clock, Context) ->
|
||||
Attrs = mk_limit_log_attributes(Context),
|
||||
lists:foreach(
|
||||
fun(#domain_TurnoverLimit{id = ID, upper_boundary = UpperBoundary, domain_revision = DomainRevision}) ->
|
||||
#limiter_Limit{amount = LimitAmount} = hg_limiter_client:get(ID, DomainRevision, Clock, Context),
|
||||
ok = logger:log(notice, "Limit change commited", [], #{
|
||||
limit => Attrs#{config_id => ID, boundary => UpperBoundary, amount => LimitAmount}
|
||||
})
|
||||
end,
|
||||
TurnoverLimits
|
||||
).
|
||||
|
||||
mk_limit_log_attributes(#limiter_LimitContext{
|
||||
payment_processing = #context_payproc_Context{op = Op, invoice = CtxInvoice}
|
||||
}) ->
|
||||
#context_payproc_Invoice{
|
||||
invoice = #domain_Invoice{owner_id = PartyID, shop_id = ShopID},
|
||||
payment = #context_payproc_InvoicePayment{
|
||||
payment = Payment,
|
||||
refund = Refund,
|
||||
route = #base_Route{provider = Provider, terminal = Terminal}
|
||||
}
|
||||
} = CtxInvoice,
|
||||
#domain_Cash{amount = Amount, currency = Currency} =
|
||||
case Op of
|
||||
{invoice_payment, #context_payproc_OperationInvoicePayment{}} ->
|
||||
Payment#domain_InvoicePayment.cost;
|
||||
{invoice_payment_refund, #context_payproc_OperationInvoicePaymentRefund{}} ->
|
||||
Refund#domain_InvoicePaymentRefund.cash
|
||||
end,
|
||||
#{
|
||||
config_id => undefined,
|
||||
%% Limit boundary amount
|
||||
boundary => undefined,
|
||||
%% Current amount with accounted change
|
||||
amount => undefined,
|
||||
route => #{
|
||||
provider_id => Provider#domain_ProviderRef.id,
|
||||
terminal_id => Terminal#domain_TerminalRef.id
|
||||
},
|
||||
party_id => PartyID,
|
||||
shop_id => ShopID,
|
||||
change => #{
|
||||
amount => Amount,
|
||||
currency => Currency
|
||||
}
|
||||
}.
|
||||
|
10
compose.yaml
10
compose.yaml
@ -27,7 +27,7 @@ services:
|
||||
command: /sbin/init
|
||||
|
||||
dominant:
|
||||
image: ghcr.io/valitydev/dominant:sha-ecd7531
|
||||
image: ghcr.io/valitydev/dominant:sha-fdf5277
|
||||
command: /opt/dominant/bin/dominant foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
@ -39,7 +39,7 @@ services:
|
||||
retries: 10
|
||||
|
||||
machinegun:
|
||||
image: ghcr.io/valitydev/machinegun:sha-058bada
|
||||
image: ghcr.io/valitydev/machinegun:sha-ed72eec
|
||||
command: /opt/machinegun/bin/machinegun foreground
|
||||
volumes:
|
||||
- ./test/machinegun/config.yaml:/opt/machinegun/etc/config.yaml
|
||||
@ -51,7 +51,7 @@ services:
|
||||
retries: 20
|
||||
|
||||
bender:
|
||||
image: ghcr.io/valitydev/bender:sha-d05ea29
|
||||
image: ghcr.io/valitydev/bender:sha-c9ea00f
|
||||
command: /opt/bender/bin/bender foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
@ -63,7 +63,7 @@ services:
|
||||
retries: 10
|
||||
|
||||
limiter:
|
||||
image: ghcr.io/valitydev/limiter:sha-2b8723b
|
||||
image: ghcr.io/valitydev/limiter:sha-6c3bfe3
|
||||
command: /opt/limiter/bin/limiter foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
@ -98,7 +98,7 @@ services:
|
||||
retries: 40
|
||||
|
||||
party-management:
|
||||
image: ghcr.io/valitydev/party-management:sha-4a94036
|
||||
image: ghcr.io/valitydev/party-management:sha-18bba50
|
||||
command: /opt/party-management/bin/party-management foreground
|
||||
depends_on:
|
||||
machinegun:
|
||||
|
@ -68,3 +68,7 @@ storage:
|
||||
woody_server:
|
||||
max_concurrent_connections: 8000
|
||||
http_keep_alive_timeout: 15S
|
||||
|
||||
logging:
|
||||
out_type: stdout
|
||||
level: info
|
||||
|
Loading…
Reference in New Issue
Block a user