GenDurable.Outcome (gen_durable v0.1.8)

Copy Markdown View Source

The step/handle outcomes, with shape validation.

{:next, step, state}        # transition, runnable, attempt := 0
{:next, step, state, opts}  # …with per-transition opts: rate_limit, weight
{:retry, state, delay_ms}   # same step, runnable, attempt += 1, eligible_at += delay
{:await, names, next_step, state} # park; on any of `names`, run next_step (ctx.awaited)
{:done, result}             # terminal, done
{:stop, reason}             # terminal, failed

Step names and signal names are normalized to strings. :await accepts a single name or a list of names; both normalize to a list. :next accepts an optional 4th keyword opts (rate_limit:, weight:); it is normalized to a next_opts map and the outcome to the 4-tuple {:next, step, state, opts_map}.

Summary

Functions

The outcome's tag, for telemetry/metadata.

Types

next_opts()

@type next_opts() :: %{rate_limit: String.t() | nil, weight: number()}

t()

@type t() ::
  {:next, String.t(), term(), next_opts()}
  | {:retry, term(), non_neg_integer()}
  | {:await, [String.t()], String.t(), term()}
  | {:schedule_childs, String.t(), [term()], term()}
  | {:done, map()}
  | {:stop, term()}

Functions

kind(outcome)

The outcome's tag, for telemetry/metadata.

validate(other)

@spec validate(term()) :: {:ok, t()} | {:error, {:bad_outcome, term()}}

validate!(outcome)

@spec validate!(term()) :: t()