Skip to content

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

ParameterTypeDescription
namestringQueue name (used for topic and subscription naming).
processor`(signal: AbortSignal, data: T) => RPromise<R>`
optsJobQueueOptions&lt;T&gt;Queue configuration.

Returns

JobQueue&lt;T, R&gt; — queue with add, event subscription, companion stores, and lifecycle.

Released under the MIT License.