Skip to content

Latest commit

 

History

History
76 lines (65 loc) · 5.63 KB

bullmq.job.md

File metadata and controls

76 lines (65 loc) · 5.63 KB

Home > bullmq > Job

Job class

Signature:

export declare class Job<DataType = any, ReturnType = any, NameType extends string = string> 

Constructors

Constructor Modifiers Description
(constructor)(queue, name, data, opts, id) Constructs a new instance of the Job class

Properties

Property Modifiers Type Description
attemptsMade number Number of attempts after the job has failed.
data DataType The payload for this job.
failedReason string Reason for failing.
finishedOn? number (Optional) Timestamp for when the job finished (completed or failed).
id? string (Optional)
name NameType The name of the Job
opts JobsOptions The options object for this job.
parent? { id: string; queueKey: string; } (Optional)
parentKey? string (Optional) Fully qualified key (including the queue prefix) pointing to the parent of this job.
processedOn? number (Optional) Timestamp for when the job was processed.
progress number | object The progress a job has performed so far.
queue MinimalQueue
queueName string
returnvalue ReturnType The value returned by the processor when processing this job.
stacktrace string[] Stacktrace for the error (for failed jobs).
timestamp number Timestamp when the job was created (unless overridden with job options).
toKey (type: string) => string

Methods

Method Modifiers Description
addJob(client, parentOpts) Adds the job to Redis.
asJSON() Prepares a job to be serialized for storage in Redis.
changeDelay(delay) Change delay of a delayed job.
create(queue, name, data, opts) static Creates a new job and adds it to the queue.
createBulk(queue, jobs) static Creates a bulk of jobs and adds them atomically to the given queue.
discard() Marks a job to not be retried if it fails (even if attempts has been configured)
extendLock(token, duration) Extend the lock for this job.
fromId(queue, jobId) static Fetches a Job from the queue given the passed job id.
fromJSON(queue, json, jobId) static Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)
getChildrenValues() Get this jobs children result values if any.
getDependencies(opts) Get children job keys if this job is a parent and has children.
getDependenciesCount(opts) Get children job counts if this job is a parent and has children.
getState() Get current state.
isActive()
isCompleted()
isDelayed()
isFailed()
isWaiting()
isWaitingChildren()
log(logRow) Logs one row of log data.
moveToCompleted(returnValue, token, fetchNext) Moves a job to the completed queue. Returned job to be used with Queue.prototype.nextJobFromJobData.
moveToDelayed(timestamp) Moves the job to the delay set.
moveToFailed(err, token, fetchNext) Moves a job to the failed queue.
moveToWaitingChildren(token, opts) Moves the job to the waiting-children set.
promote() Promotes a delayed job so that it starts to be processed as soon as possible.
remove() Completely remove the job from the queue. Note, this call will throw an exception if the job is being processed when the call is performed.
retry(state) Attempts to retry the job. Only a job that has failed can be retried.
toJSON()
update(data) Updates a job's data
updateProgress(progress) Updates a job's progress
waitUntilFinished(queueEvents, ttl) Returns a promise the resolves when the job has finished. (completed or failed).