GenDurable.Outcome (gen_durable v0.2.0)

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
{:await, names, next_step, state, opts} # …with opts: timeout (ms; wake with what's
                                        # in the inbox when it fires)
{: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:), :await an optional 5th (timeout:); both normalize to an opts map in the tuple's last position.

Summary

Functions

The outcome's tag, for telemetry/metadata.

Types

await_opts()

@type await_opts() :: %{timeout: pos_integer() | nil}

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(), await_opts()}
  | {: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()