Nebo15 / sage

A dependency-free tool to run distributed transactions in Elixir, inspired by Sagas pattern.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support plug-style callback module as a step argument

AndrewDryga opened this issue · comments

MFA's are rather ugly and I'm not sure why someone would use them, resulting code is harder to read. We might build a Sage.Operation behavior with two callbacks:

# required
@callback transaction(effects_so_far :: effects(), execute_opts :: any()) ::  {:ok | :error | :abort, any()}

# optional
@callback compensation(effect_to_compensate :: any(),
           effects_so_far :: effects(),
           execute_opts :: any()) :: :ok | :abort | {:retry, retry_opts :: retry_opts()} | {:continue, any()}

Introducing this change and removing MFA would help to make sure that saga can be type checked #17.