Job
Job
A Job represents a piece of work to be run in the background, i.e. outside the request-response cycle.
It is intended to be used for long-running work triggered by API requests. Jobs should now generally
be directly instantiated. Rather, the JobQueue add()
method should be used to create and
add a new Job to a queue.
Signature
class Job<T extends JobData<T> = any> {
readonly id: number | string | null;
readonly queueName: string;
readonly retries: number;
readonly createdAt: Date;
name: string
data: T
state: JobState
progress: number
result: any
error: any
isSettled: boolean
startedAt: Date | undefined
settledAt: Date | undefined
duration: number
attempts: number
constructor(config: JobConfig<T>)
start() => ;
setProgress(percent: number) => ;
complete(result?: any) => ;
fail(err?: any) => ;
cancel() => ;
defer() => ;
on(eventType: JobEventType, listener: JobEventListener<T>) => ;
off(eventType: JobEventType, listener: JobEventListener<T>) => ;
}