Skip to content

State machine

State machine

pending ──▶ running ──▶ completed
                   └──▶ failed

Terminal states (completed, failed) never move again. Any illegal transition throws IllegalOperationTransition.

Steps

An operation carries an ordered list of steps, each pending → running → completed. start() sets the first step running; advanceStep(step) completes that step and promotes the next pending one. Advancing an already-completed step is an idempotent no-op — safe for at-least-once workers. Advancing an unknown step name throws UnknownOperationStep.

Idempotency

complete() on a completed operation and fail() on a terminal operation are no-ops that preserve the first outcome, so a retried worker never overwrites a result or double-dispatches an event.