Synchronous, deterministic execution for tests: drain/3 claims and runs
ready jobs in the calling process until the queue is empty, following
workflow releases as they happen.
Summary
Functions
Drain a queue synchronously. Only claims jobs that are due at the current
clock time — advance a Belay.Clock.Sim to reach scheduled work.
Functions
@spec drain(Belay.instance(), atom() | String.t(), keyword()) :: %{ optional(atom()) => non_neg_integer() }
Drain a queue synchronously. Only claims jobs that are due at the current
clock time — advance a Belay.Clock.Sim to reach scheduled work.
Returns counts of executions by the state each one left its job in, not counts of jobs:
%{succeeded: 3, failed: 1}A job that fails and then succeeds inside the same drain therefore appears
twice — once under :ready (the retry) and once under :succeeded. Parked
jobs count under :awaiting, snoozes and retries under :ready, and an
execution whose ack lost the attempt fence under :stale.