Jobs composed with directed acyclic dependencies.
alias Belay.Workflow
{:ok, jobs} =
Workflow.new()
|> Workflow.add(:fetch, MyApp.Fetch.new(%{"id" => 1}))
|> Workflow.add(:parse, MyApp.Parse.new(%{}), deps: [:fetch])
|> Workflow.add(:store, MyApp.Store.new(%{}), deps: [:parse])
|> Workflow.insert(MyBelay)Dependent jobs are inserted held and released transactionally as their
upstreams succeed. When an upstream fails or is cancelled, dependents cancel
by default; ignore: [:failed] / ignore: [:cancelled] (per job or
workflow-wide) treats that outcome as satisfied instead.
Summary
Functions
Add a named job. deps must reference previously added names.
Insert all workflow jobs atomically. Returns {:ok, %{name => job}}.
All jobs in a workflow.
Create a workflow. Options: :workflow_id, :ignore ([:failed | :cancelled]).
Status summary: %{total:, state_counts:, done?:}.
Types
@type status() :: %{ total: non_neg_integer(), state_counts: %{optional(String.t()) => non_neg_integer()}, done?: boolean() }
Functions
Add a named job. deps must reference previously added names.
@spec insert(t(), Belay.instance()) :: {:ok, %{required(String.t()) => Belay.Job.t()}}
Insert all workflow jobs atomically. Returns {:ok, %{name => job}}.
@spec jobs(Belay.instance(), String.t()) :: [Belay.Job.t()]
All jobs in a workflow.
Create a workflow. Options: :workflow_id, :ignore ([:failed | :cancelled]).
@spec status(Belay.instance(), String.t()) :: status()
Status summary: %{total:, state_counts:, done?:}.