Belay.Replay (Belay v1.0.0)

Copy Markdown View Source

Time-travel debugging: re-run a job's code against its recorded journal.

case Belay.Replay.dry_run(MyBelay, job_id) do
  {:ok, result, trace} -> ...      # code path fully covered by the journal
  {:blocked, why, trace} -> ...    # hit something the recording never saw
  {:raised, error, trace} -> ...   # the code itself raised during replay
end

In a dry run every memoized read (steps, sleeps, spawns) returns its recorded value, emit/2 and debit/3 are inert, and nothing else touches the world. That makes two workflows possible:

  • Post-mortem — replay a failed job locally and step through the exact decisions it made, with the exact intermediate values it saw.
  • Divergence detection — after changing worker code, replay recorded jobs: {:blocked, {:missing_step, name}, _} pinpoints where the new code's path departs from what production actually executed.

Dry runs never ack, never consume attempts, and are safe against live jobs.

Summary

Functions

Replay job_id's worker against its journal without side effects.

Types

trace()

@type trace() :: [map()]

Functions

dry_run(name, job_id)

@spec dry_run(term(), integer()) ::
  {:ok, term(), trace()}
  | {:blocked, term(), trace()}
  | {:raised, {atom(), term()}, trace()}
  | {:error, :not_found}

Replay job_id's worker against its journal without side effects.