Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Latest commit

 

History

History
177 lines (124 loc) · 5.49 KB

API.md

File metadata and controls

177 lines (124 loc) · 5.49 KB

Classes

Connection
Job
Worker

Connection

Kind: global class

new Connection(uri, options)

Param Type Description
uri string MongoDB connection string
options Object connection options

connection.worker(queues, options)

Returns a new Worker

Kind: instance method of Connection

Param Type Description
queues Array.<string> | string list of queue names, a single queue name, or '*' for a universal worker
options Object an object with worker options

Job

Kind: global class

new Job(collection, data)

Param Type Description
collection string The collection to save the job to
data Object The Job data

Job~Attempts : Object

Job retry specification

Kind: inner typedef of Job
Properties

Name Type Description
strategy string Name of Worker~strategyCallback to use on retry
count number total number of attempts so far
delay number a delay constant for use in determining a delay. In default linear strategy, this will be the delay between attempts

Worker

Kind: global class

new Worker(queues, options)

Param Type Description
queues Array.<string> an array of queue names that this worker will listen for
options Options Options Options object

worker.register(callbacks)

Sets handlers to be invoked for each queue that the worker is listening to

Kind: instance method of Worker

Param Type Description
callbacks Object map of Callback objects. Keys are the name of the queue, values are the handlers for those queues

worker.start()

Starts the worker. If no queues have been specified yet, this will loop

Kind: instance method of Worker

worker.stop()

Stops the worker

Kind: instance method of Worker

worker.addQueue(queue)

Adds a queue for the worker to listen on

Kind: instance method of Worker

Param Type Description
queue string the name of the queue to add

Worker~Options : Object

Options for a new worker

Kind: inner typedef of Worker
Properties

Name Type Description
interval Number the polling interval for the worker. Note: The worker will process jobs, one at a time, as fast as possible while queues have waiting jobs
strategies Strategies Strategies for retrying jobs
callbacks Worker~Callbacks Map of Callback for processing jobs
minPriority Number The lowest job priority the worker will process

Worker~Callback : function

Job handler functions should take this form

Kind: inner typedef of Worker

Param Type Description
params Job.params Job.params object for the job to be processed
callback function NodeJS style callback to be invoked when job processing is finished

Worker~Strategies : Object

A map of StrategyCallbacks

Kind: inner typedef of Worker

Worker~StrategyCallback ⇒ Number

Kind: inner typedef of Worker
Returns: Number - delay time

Param Type Description
attempts Attempts Attempts object