jobQueue()
Create a job queue backed by a topic and shared subscription.
Each call to add(data) publishes a message to the underlying topic. The queue pulls messages, runs them through the processor function with concurrency control, and tracks per-job status. Event listeners fire on completion, failure, and stall detection.
Signature
ts
function jobQueue<T, R = void>(
name: string,
processor: (signal: AbortSignal, data: T) => R | Promise<R>,
opts?: JobQueueOptions<T>,
): JobQueue<T, R>Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Queue name (used for topic and subscription naming). |
processor | `(signal: AbortSignal, data: T) => R | Promise<R>` |
opts | JobQueueOptions<T> | Queue configuration. |
Returns
JobQueue<T, R> — queue with add, event subscription, companion stores, and lifecycle.