Skip to main content
A JobRun represents a single execution instance of a Job. It tracks the state, payload, result, and timing of the execution.

JobRun Model

The JobRun struct (defined in apps/strait/internal/domain/types.go) contains the following fields:

Finite State Machine (FSM)

The lifecycle of a run is strictly managed by a 13-state FSM.

FSM Diagram

Valid Transitions

Status Descriptions

  • delayed: Run is created but scheduled for a future time.
  • queued: Ready to be picked up by a worker.
  • dequeued: Claimed by a worker but not yet started.
  • executing: HTTP request has been dispatched to the job endpoint.
  • waiting: Paused, typically waiting for a child run or external signal.
  • completed: Finished successfully (2xx response).
  • failed: Finished with an error (non-2xx response) and no retries left.
  • timed_out: Execution exceeded the configured timeout_secs.
  • crashed: Worker process terminated unexpectedly while executing.
  • system_failed: Internal Strait error (e.g., database failure).
  • canceled: Manually terminated by a user or system.
  • expired: Run exceeded its run_ttl_secs before starting.
  • dead_letter: Permanently failed run moved to the DLQ for manual inspection.

Terminal vs Non-Terminal States

A run is considered terminal when it reaches a state where no further automatic transitions occur (except for manual DLQ replay).
Terminal states: completed, failed, timed_out, crashed, system_failed, canceled, expired.

Execution Trace

The execution_trace field captures granular timing:
  • queue_wait_ms: Time spent in queued state.
  • dequeue_ms: Time taken to claim the run.
  • connect_ms: TCP/TLS connection time to the endpoint.
  • ttfb_ms: Time to first byte of the response.
  • transfer_ms: Time to download the response body.
  • total_ms: Total wall-clock time for the execution.

Debug Mode and Lineage

  • Debug Mode: Enables detailed event logging and allows assembly of a “Debug Bundle” for troubleshooting.
  • Continuation Lineage: Tracks the relationship between runs when one run triggers another as a continuation, maintaining a lineage_depth and continuation_of reference.