TD-366: Make session finalization idempotent (#42)

This commit is contained in:
Alexey S 2022-08-29 17:42:46 +03:00 committed by GitHub
parent 0b993f44a6
commit e28ecaa408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

2
.env
View File

@ -2,6 +2,6 @@
# You SHOULD specify point releases here so that build time and run time Erlang/OTPs # 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 # are the same. See: https://github.com/erlware/relx/pull/902
SERVICE_NAME=fistful-server SERVICE_NAME=fistful-server
OTP_VERSION=24.2.0 OTP_VERSION=24.3
REBAR_VERSION=3.18 REBAR_VERSION=3.18
THRIFT_VERSION=0.14.2.3 THRIFT_VERSION=0.14.2.3

View File

@ -972,9 +972,11 @@ create_session(ID, TransferData, SessionParams) ->
-spec finalize_session(session_id(), session_result(), withdrawal_state()) -> -spec finalize_session(session_id(), session_result(), withdrawal_state()) ->
{ok, process_result()} | {error, finalize_session_error()}. {ok, process_result()} | {error, finalize_session_error()}.
finalize_session(SessionID, Result, Withdrawal) -> finalize_session(SessionID, Result, Withdrawal) ->
case session_id(Withdrawal) of case {session_id(Withdrawal), get_current_session_status(Withdrawal)} of
SessionID -> {SessionID, pending} ->
{ok, {continue, [{session_finished, {SessionID, Result}}]}}; {ok, {continue, [{session_finished, {SessionID, Result}}]}};
{SessionID, _} ->
{ok, {undefined, []}};
_OtherSessionID -> _OtherSessionID ->
{error, {wrong_session_id, SessionID}} {error, {wrong_session_id, SessionID}}
end. end.