Bound session poll timeouts during withdrawal processing (#50)

This commit is contained in:
Andrew Mayorov 2019-01-17 11:52:58 +03:00 committed by GitHub
parent 93a439ddaa
commit 6001bfd993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -128,6 +128,8 @@ transfer(St) ->
%% Machinery
-define(MAX_SESSION_POLL_TIMEOUT, 4 * 60 * 60).
-type machine() :: ff_machine:machine(event(_)).
-type result() :: ff_machine:result(event(_)).
-type handler_opts() :: machinery:handler_opts(_).
@ -181,9 +183,12 @@ set_action(undefined, _St) ->
undefined;
set_action(poll, St) ->
Now = machinery_time:now(),
Timeout = erlang:max(1, machinery_time:interval(Now, ff_machine:updated(St)) div 1000),
{set_timer, {timeout, Timeout}}.
{set_timer, {timeout, compute_poll_timeout(Now, St)}}.
compute_poll_timeout(Now, St) ->
MaxTimeout = genlib_app:env(ff_transfer, max_session_poll_timeout, ?MAX_SESSION_POLL_TIMEOUT),
Timeout0 = machinery_time:interval(Now, ff_machine:updated(St)) div 1000,
erlang:min(MaxTimeout, erlang:max(1, Timeout0)).
%% Handler convertors

View File

@ -99,7 +99,8 @@
}
}
}
}}
}},
{max_session_poll_timeout, 14400} %% 4h
]},
%% wapi