Class: Coordinator

Coordinator

new Coordinator(db, options)

lib/Coordinator.js, line 32

Create a coordinator using the given mongodb driver connection. If you're using mongoose, you can access it with mongoose.db.

Name Type Description
db Object
options Object optional
Name Type Default Description
collection string '_tasks' optional

collection to use

Extends

  • EventEmitter

Members

dbObject

Methods

schedule(options, fn){Task}

lib/Coordinator.js, line 84

Schedule a task to run at a fixed interval. The interval may be represented as a string, see time

Name Type Description
options Object
Name Type Default Description
name string

task name. Only one instance of this task will run at a time

interval number | string

timer interval (in ms) to repeat the task

offset number | string 0 optional

offset from whole intervals to run this task

timeout number | string interval optional

lock expire time. Set to 0 to disable timeout

fn Coordinator~runTask
Returns:
Type Description
Task

Type Definitions

runTask(done)

lib/Coordinator.js, line 62

Task implementation

Name Type Description
done Coordinator~taskDone

taskDone()

lib/Coordinator.js, line 68

Tell the coordinator the task has completed

Events

possibleOverrun

lib/Coordinator.js, line 16

Acquired a lock that timeouted The task may be running somewhere else

Type:

timeout

lib/Coordinator.js, line 9

A task running on this instance timeouted It may have crashed before calling done() or just forgot to do so

Type: