Insert a group of jobs and run a callback when the whole group has finished
— thin, transparent sugar over Belay.Workflow.
{:ok, batch_id, jobs} =
Belay.Batch.insert(MyBelay, changeset_list,
on_complete: MyApp.Notify.new(%{"channel" => "#imports"}))The callback job runs once every batch member is terminal, whatever the
outcomes were, and receives "batch_id" merged into its input — read
Belay.Batch.status/2 there for the final counts. Batch members are
ordinary workflow jobs: cancel them, retry them, and inspect them with the
normal APIs.
Summary
Functions
Insert buildables as a batch. Options
All jobs in the batch, callback included.
Batch status: %{total:, state_counts:, done?:} (callback included).
Functions
@spec insert(Belay.instance(), [Belay.buildable()], keyword()) :: {:ok, String.t(), %{required(String.t()) => Belay.Job.t()}}
Insert buildables as a batch. Options:
:on_complete— aWorker.new/2build to run after every member finishes (any outcome):batch_id— override the generated id
Returns {:ok, batch_id, jobs_by_name}.
@spec jobs(Belay.instance(), String.t()) :: [Belay.Job.t()]
All jobs in the batch, callback included.
@spec status(Belay.instance(), String.t()) :: Belay.Workflow.status()
Batch status: %{total:, state_counts:, done?:} (callback included).