Zizq.Job (Zizq v0.6.0)

Copy Markdown View Source

A job record from the server.

Returned by Zizq.enqueue/2, yielded by the take stream, and listed by the query API. Which fields are populated depends on the job's lifecycle state — :dequeued_at is only set once a worker has taken it, :completed_at only once it has finished — so treat anything optional as possibly nil.

Timestamps are DateTime.t/0 in UTC.

Summary

Types

Lifecycle state.

t()

Types

status()

@type status() :: :scheduled | :ready | :in_flight | :completed | :dead

Lifecycle state.

  • :scheduled — stored, but scheduled for a future date/time and not eligible until :ready_at is reached — also used for retries when :attempts is non-zero
  • :ready — queued and waiting for a worker when it reaches the too of the queue
  • :in_flight — delivered to a worker, awaiting acknowledgement
  • :completed — finished successfully
  • :dead — failed and exhausted its retry limit

t()

@type t() :: %Zizq.Job{
  attempts: non_neg_integer(),
  backoff: Zizq.Backoff.t() | nil,
  batch: Zizq.BatchConfig.t() | nil,
  completed_at: DateTime.t() | nil,
  dequeued_at: DateTime.t() | nil,
  duplicate: boolean() | nil,
  failed_at: DateTime.t() | nil,
  folded: boolean() | nil,
  id: String.t(),
  payload: term(),
  priority: non_neg_integer(),
  purge_at: DateTime.t() | nil,
  queue: String.t(),
  ready_at: DateTime.t() | nil,
  retention: Zizq.Retention.t() | nil,
  retry_limit: non_neg_integer() | nil,
  status: status(),
  type: String.t(),
  unique_key: String.t() | nil,
  unique_while: String.t() | nil
}