Durable.Definition.Compensation (Durable v0.1.0-rc)
View SourceRepresents a compensation handler for a step.
Compensations are executed in reverse order when a workflow fails and needs to undo previously completed steps (Saga pattern).
Pipeline Model
Compensation functions receive the current data and return {:ok, data}:
compensate :cancel_flight, fn data ->
FlightAPI.cancel(data.flight_booking_id)
{:ok, data}
end
Summary
Functions
Executes the compensation with the given data.
Types
@type t() :: %Durable.Definition.Compensation{ body_fn: (map() -> {:ok, map()} | {:error, term()}) | nil, module: module(), name: atom(), opts: %{ optional(:retry) => Durable.Definition.Step.retry_opts(), optional(:timeout) => pos_integer() } }