Job
A job includes all data needed to perform its execution, as well as the progress method needed to update its progress.
The most important property for the user is Job#data
that includes the object that was passed to Queue#add
, and that is normally used to perform the job.
Job#progress
Updates a job progress if called with an argument. Return a promise resolving to the current job's progress if called without argument.
Arguments
progress: number; Job progress number or any serializable object representing progress or similar.
Job#log
Adds a log row to this job specific job. Logs can be retrieved using Queue#getJobLogs.
Job#getState
Returns a promise resolving to the current job's status (completed, failed, delayed etc.). Possible returns are: completed, failed, delayed, active, waiting, paused, stuck or null.
Please take note that the implementation of this method is not very efficient, nor is it atomic. If your queue does have a very large quantity of jobs, you may want to avoid using this method.
Job#update
Updated a job data field with the give data object.
Job#remove
Removes a job from the queue and from any lists it may be included in.
Job#retry
Re-run a job that has failed. Returns a promise that resolves when the job is scheduled for retry.
Job#discard
Ensure this job is never ran again even if attemptsMade
is less than job.attempts
.
Job#promote
Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible.
Job#finished
Returns a promise that resolves or rejects when the job completes or fails.
Job#moveToCompleted
moveToCompleted(returnValue: any, ignoreLock: boolean, notFetch?: boolean): Promise<string[Jobdata, JobId] | null>
Moves a job to the completed
queue. Pulls a job from 'waiting' to 'active' and returns a tuple containing the next jobs data and id. If no job is in the waiting
queue, returns null. Set notFetch
to true to avoid prefetching the next job in the queue.
Job#moveToFailed
moveToFailed(errorInfo:{ message: string; }, ignoreLock?:boolean): Promise<string[Jobdata, JobId] | null>
Moves a job to the failed
queue. Pulls a job from 'waiting' to 'active' and returns a tuple containing the next jobs data and id. If no job is in the waiting
queue, returns null.