Belay.Job (Belay v1.0.0)

Copy Markdown View Source

The durable job record.

States:

  • "ready" — claimable once ready_at is due (covers scheduled, retry backoff, and snoozes; there is no separate staging step)
  • "awaiting" — parked on a named signal; ready_at doubles as the wake deadline (nil waits forever)
  • "running" — claimed under a lease
  • "held" — created but ineligible (unmet workflow deps, operator hold)
  • "succeeded" / "failed" / "cancelled" — terminal
  • "paused" — reserved for operator freezes of parked jobs

Summary

Functions

All non-terminal state names.

Decode a succeeded job's result (ETF or JSON — see Belay.Codec).

Whether a job is in a terminal state.

All terminal state names.

Types

t()

@type t() :: %Belay.Job{
  attempt: non_neg_integer() | nil,
  await_name: String.t() | nil,
  await_scope: String.t() | nil,
  budget_tokens: non_neg_integer() | nil,
  budget_usd_micros: non_neg_integer() | nil,
  cancel_requested: boolean() | nil,
  cron_name: String.t() | nil,
  cron_slot: DateTime.t() | nil,
  duplicate?: boolean(),
  errors: [map()] | nil,
  finished_at: DateTime.t() | nil,
  id: integer() | nil,
  input: map() | nil,
  inserted_at: DateTime.t() | nil,
  kind: String.t() | nil,
  lease_until: DateTime.t() | nil,
  leased_by: String.t() | nil,
  max_attempts: pos_integer() | nil,
  meta: map() | nil,
  parent_id: integer() | nil,
  partition_key: String.t() | nil,
  priority: integer() | nil,
  queue: String.t() | nil,
  ready_at: DateTime.t() | nil,
  result: binary() | nil,
  spent_tokens: non_neg_integer() | nil,
  spent_usd_micros: non_neg_integer() | nil,
  started_at: DateTime.t() | nil,
  state: String.t() | nil,
  unique_key: String.t() | nil,
  unique_mode: String.t() | nil,
  wf_deps: [String.t()] | nil,
  wf_ignore: [String.t()] | nil,
  wf_name: String.t() | nil,
  workflow_id: String.t() | nil
}

Functions

incomplete_states()

@spec incomplete_states() :: [String.t()]

All non-terminal state names.

result(job)

@spec result(t()) :: term()

Decode a succeeded job's result (ETF or JSON — see Belay.Codec).

terminal?(job)

@spec terminal?(t()) :: boolean()

Whether a job is in a terminal state.

terminal_states()

@spec terminal_states() :: [String.t()]

All terminal state names.