Closed mtarnovan closed 4 years ago
SAGE 0.4, after a compensation runs, the transaction is being passed effects_so_far as expected:
effects_so_far
iex(1)> (Sage.new() ...(1)> |> Sage.run(:invoice, fn _, _ -> {:ok, "invoice"} end) ...(1)> |> Sage.run( ...(1)> :some_step, ...(1)> fn a, b -> ...(1)> IO.puts "some_step called with a=#{inspect(a)} b=#{inspect(b)}" ...(1)> if :rand.uniform(10) >= 3 do ...(1)> IO.puts "error" ...(1)> {:error, "some_error"} ...(1)> else ...(1)> IO.puts "ok" ...(1)> {:ok, "some_result"} ...(1)> end ...(1)> end, ...(1)> fn _, _, _, _ -> ...(1)> {:retry, retry_limit: 10, base_backoff: 1, max_backoff: 1, enable_jitter: false} ...(1)> end ...(1)> ) ...(1)> |> Sage.transaction(Ypsilon.Repo)) some_step called with a=%{invoice: "invoice"} b=[] error some_step called with a=%{invoice: "invoice"} b=[] error some_step called with a=%{invoice: "invoice"} b=[] error some_step called with a=%{invoice: "invoice"} b=[] error some_step called with a=%{invoice: "invoice"} b=[] error some_step called with a=%{invoice: "invoice"} b=[] ok {:ok, "some_result", %{invoice: "invoice", some_step: "some_result"}}
SAGE 0.6, after a compensation runs, the transaction is being passed an empty effects_so_far
iex(1)> (Sage.new() ...(1)> |> Sage.run(:invoice, fn _, _ -> {:ok, "invoice"} end) ...(1)> |> Sage.run( ...(1)> :some_step, ...(1)> fn a, b -> ...(1)> IO.puts "some_step called with a=#{inspect(a)} b=#{inspect(b)}" ...(1)> if :rand.uniform(10) >= 3 do ...(1)> IO.puts "error" ...(1)> {:error, "some_error"} ...(1)> else ...(1)> IO.puts "ok" ...(1)> {:ok, "some_result"} ...(1)> end ...(1)> end, ...(1)> fn _, _, _ -> ...(1)> {:retry, retry_limit: 10, base_backoff: 1, max_backoff: 1, enable_jitter: false} ...(1)> end ...(1)> ) ...(1)> |> Sage.transaction(Ypsilon.Repo)) some_step called with a=%{invoice: "invoice"} b=[] error some_step called with a=%{} b=[] ok {:ok, "some_result", %{some_step: "some_result"}}
Should be fixed in #53
Thanks for fixing this so fast, much appreciated
That thanks should go to @aspett, ❤️
SAGE 0.4, after a compensation runs, the transaction is being passed
effects_so_far
as expected:SAGE 0.6, after a compensation runs, the transaction is being passed an empty
effects_so_far