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

Provide a way to accept retry only when failure appeared on the same stage

AndrewDryga opened this issue · comments

The use case is described in #50

Hi! Just jumping in to provide another use case we were using the {stage_name, failure} tuple for:

we're using Tesla's fuse middleware to handle circuit breaking when calling upstream services, and we get {:error, :unavailable} when the fuse melts. So at the moment one of our compensations' clauses is defined as following:

 defp undo_user_update(_, _, {:update_user, :unavailable}, _) do
    Logger.warn("update_user -> unavailable service, retrying")
    {:retry, retry_limit: 2, base_backoff: 10}
  end

For this reason, unless I'm missing something from the new API, we're currently unable to update to 0.6 because that would mean losing the ability to intercept circuit breaks and properly retry the steps.

Do you have any suggestion on how to proceed?