Overview
The Worker class represents a worker that processes jobs from the queue. As soon as the class is instantiated and a connection to Redis is established, it will start processing jobs.Constructor
The name of the queue to process
The processor function or path to processor file
Configuration options for the worker
Example
Properties
id
concurrency
opts
Methods
run
Starts processing jobs from the queue.pause
Pauses the processing of jobs for this worker.If true, does not wait for active jobs to finish
resume
Resumes processing jobs after being paused.isPaused
Checks if the worker is currently paused.isRunning
Checks if the worker is currently running.getNextJob
Manually fetches the next job from the queue.Worker token to assign to retrieved job
Whether to block waiting for a job
cancelJob
Cancels a specific job currently being processed.The ID of the job to cancel
Optional reason for cancellation
True if the job was found and cancelled
cancelAllJobs
Cancels all jobs currently being processed by this worker.Optional reason for cancellation
close
Closes the worker and related Redis connections.If true, does not wait for current jobs to be processed
