Overview
The Job class represents a job in the queue. Jobs are normally created implicitly when you add a job to the queue withQueue.add(), but a Job instance is also passed to the Worker’s process function.
Constructor
Jobs are typically created using
Queue.add() rather than instantiating directly.Properties
id
name
data
opts
progress
returnvalue
stacktrace
timestamp
attemptsMade
attemptsStarted
delay
priority
processedOn
finishedOn
failedReason
Static Methods
create
Creates a new job and adds it to the queue.createBulk
Creates a bulk of jobs and adds them atomically to the queue.fromId
Fetches a Job from the queue by ID.Methods
updateProgress
Updates a job’s progress.Number or object to be saved as progress
updateData
Updates a job’s data.The data that will replace the current job’s data
log
Logs one row of log data.String with log data to be logged
The total number of log entries for this job
remove
Completely removes the job from the queue.Whether to remove child jobs
retry
Attempts to retry the job.The state from which to retry (completed or failed)
Retry options
promote
Promotes a delayed job so that it starts to be processed as soon as possible.changeDelay
Changes the delay of a delayed job.Milliseconds from now when the job should be processed
changePriority
Changes the priority of a job.New priority value
Whether to add to the left (LIFO) or right (FIFO)
getState
Gets the current state of the job.One of: ‘completed’, ‘failed’, ‘delayed’, ‘active’, ‘waiting’, ‘waiting-children’, ‘unknown’
isCompleted
Checks if the job has completed.isFailed
Checks if the job has failed.isDelayed
Checks if the job is delayed.isActive
Checks if the job is active.isWaiting
Checks if the job is waiting.isWaitingChildren
Checks if the job is waiting for children.getChildrenValues
Gets the result values of child jobs.getDependencies
Gets children job keys if this job is a parent.getDependenciesCount
Gets children job counts if this job is a parent.waitUntilFinished
Returns a promise that resolves when the job has completed or rejects when failed.Instance of QueueEvents to listen for completion
Time in milliseconds to wait before timing out
moveToCompleted
Moves a job to the completed state.moveToFailed
Moves a job to the failed state.extendLock
Extends the lock for this job.Unique token for the lock
Lock duration in milliseconds
