Class: Worker

Worker

Performs tasks for jobs on a given queue.

Constructor

new Worker(opts)

Parameters:
Name Type Description
opts Object Options for the worker.
Properties
Name Type Attributes Description
done function Callback to execute when the job has successfully been completed.
job Object Data for the job to process.
queue String Name of the queue for the job the worker is processing.
task function A function to handle the tasks.
errorCat ErrorCat <optional>
An error-cat instance to use for the worker.
log bunyan <optional>
The bunyan logger to use when logging messages from the worker.
msTimeout number <optional>
A specific millisecond timeout for this worker.
runNow boolean <optional>
Whether or not to run the job immediately, defaults to `true`.
Author:
  • Bryan Kendall
  • Ryan Sandor Richards
Source:

Methods

(static) create(opts) → {Worker}

Factory method for creating new workers. This method exists to make it easier to unit test other modules that need to instantiate new workers.
Parameters:
Name Type Description
opts Object Options for the Worker.
Source:
See:
Returns:
New Worker.
Type
Worker

run() → {Promise}

Runs the worker. If the task for the job fails, then this method will retry the task (with an exponential backoff) as set by the environment.
Source:
Returns:
Promise that is resolved once the task succeeds or fails.
Type
Promise