Baton.Reschedule (Baton v0.1.0)

Copy Markdown View Source

Completion-triggered rescheduling of downstream workflow jobs.

When a step completes, rather than waiting for snoozing downstream jobs to wake on their timer, this promotes any downstream job whose dependencies are now all satisfied so Oban picks it up on its next poll (typically within a second).

Dependency information now comes from workflow_nodes (native text-array membership), so the old jsonb-containment query is gone.

Multi-dependency correctness

A downstream job with deps: [:a, :b] is only promoted once both are complete. Promoting on the first completion would just make it wake, fail its dep check, and snooze again.

Note on Oban's state machine

The final promotion does update_all(state: "available") on oban_jobs. Oban exposes no public "promote scheduled -> available" call, so this reaches into Oban's state column directly. It is the one place the engine depends on Oban's internal state names; if that ever breaks on an Oban upgrade, removing this module degrades gracefully to the snooze-timer fallback with no loss of correctness — only added latency.

Summary

Functions

Promote downstream jobs whose deps are now all complete.

Functions

reschedule_downstream(workflow_id, completed_step_name)

@spec reschedule_downstream(String.t(), String.t()) :: {:ok, non_neg_integer()}

Promote downstream jobs whose deps are now all complete.

Returns {:ok, count} with the number of jobs promoted.