Skip to main content

Types

BackoffStrategy​

Defines the backoff strategy used when retrying failed jobs. Returns the delay in ms that should pass before the failed job is retried.

Signature
type BackoffStrategy = (queueName: string, attemptsMade: number, job: Job) => number

JobUpdate​

Job update status as returned from the SubscribableJob's update() method.

Signature
type JobUpdate<T extends JobData<T>> = Pick<
Job<T>,
'id' | 'state' | 'progress' | 'result' | 'error' | 'data'
>

JobUpdateOptions​

Job update options, that you can specify by calling {@link SubscribableJob.updates updates()} method.

Signature
type JobUpdateOptions = {
pollInterval?: number;
timeoutMs?: number;
errorOnFail?: boolean;
}

pollInterval​

property
number

timeoutMs​

property
number

errorOnFail​

property
boolean

CreateQueueOptions​

Used to configure a new JobQueue instance.

Signature
interface CreateQueueOptions<T extends JobData<T>> {
name: string;
process: (job: Job<T>) => Promise<any>;
}

name​

property
string

The name of the queue, e.g. "image processing", "re-indexing" etc.

process​

property
(job: Job<T>) => Promise<any>

Defines the work to be done for each job in the queue. The returned promise should resolve when the job is complete, or be rejected in case of an error.

JobData​

A JSON-serializable data type which provides a Job with the data it needs to be processed.

Signature
type JobData<T> = JsonCompatible<T>

JobConfig​

Used to instantiate a new Job

Signature
interface JobConfig<T extends JobData<T>> {
queueName: string;
data: T;
retries?: number;
attempts?: number;
id?: ID;
state?: JobState;
progress?: number;
result?: any;
error?: any;
createdAt?: Date;
startedAt?: Date;
settledAt?: Date;
}

queueName​

property
string

data​

property
T

retries​

property
number

attempts​

property
number

id​

property

state​

property

progress​

property
number

result​

property
any

error​

property
any

createdAt​

property
Date

startedAt​

property
Date

settledAt​

property
Date