Skip to content
Français

QueueJob

import type { QueueJob } from "@elie-laloum/outpost";
  • statusRequired
    "failed" | "done" | "cancelled" | "active" | "pending"
    pending until claimed, active while leased, then done, failed or cancelled. The queue never retries a failed job.
  • fenceRequired
    number
    Lease generation: 0 at enqueue, incremented by each claim, cancellation and deadline expiry. renew() and complete() must present the current value.
  • workerOptional
    string | undefined
    Name of the worker that last claimed the job.
  • expiresOptional
    number | undefined
    Lease expiry in epoch milliseconds; once it passes, another worker can claim the job.
  • resultOptional
    QueueResult | undefined
    Result stored by complete(), present once the job is done or failed.
  • idRequired
    string
    Job ID, 1 to 512 characters and unique in the queue; enqueuing it again returns the stored job.
  • idempotencyKeyOptional
    string | undefined
    Effect key passed to the handler instead of the job ID; defineQueuedTask sets it to the original key when a quota pause republishes the task under a new job ID.
  • handlerRequired
    string
    Name of the worker handler that runs the job, 1 to 512 characters.
  • inputRequired
    WorkflowJson
    JSON input passed to the handler, at most 262144 bytes serialized.
  • deadlineOptional
    number | undefined
    Time in epoch milliseconds after which a pending or active job becomes cancelled; leases never extend past it.
export interface QueueJob extends QueueRequest {
  readonly status: "pending" | "active" | "done" | "failed" | "cancelled";
  readonly fence: number;
  readonly worker?: string;
  readonly expires?: number;
  readonly result?: QueueResult;
}