Class: Base

Base

Class representing the basics needed for a scheduler

new Schedulers.Base(options, instances)

schedulers/base.js, line 11

Create an instance

Name Type Description
options object

The options passed in to the instance

instances array

Already running worker instances

Methods

_do(event, data, callback)

schedulers/base.js, line 79

The actual method that picks a worker to send work to

Name Type Description
event string

The name of the event to send.

data

Whatever stringifyable value that is to be sent with the event.

callback function

The callback to be called when the event completes.

callInstance(instanceOrIndex, event, data, callback)

schedulers/base.js, line 60

Sends the specified worker an event to process.

Name Type Description
instanceOrIndex

Either the index of a worker or the actual worker to send event to.

event string

The name of the event to send.

data

Whatever stringifyable value that is to be sent with the event.

callback function

The callback to be called when the event completes.

checkAvailableInstances(event)

schedulers/base.js, line 29

Check that there is a worker available to perform work. Throws an error if there are no workers.

Name Type Description
event string

Name of the event to be dispatched, used for error message.

deregister(instance)

schedulers/base.js, line 45

Deregisters an instance from the avialable worker instances.

Name Type Description
instance object

The worker instance to remove.

do(event, data, callback)

schedulers/base.js, line 96

Used to select a worker and send work to it. Internally it uses _do and checkAvailableInstances to perform the worker selection and delegation.

Name Type Description
event string

The name of the event to send.

data

Whatever stringifyable value that is to be sent with the event.

callback function

The callback to be called when the event completes.

kill(signal)

schedulers/base.js, line 86

Kills a worker

Name Type Default Description
signal string SIGTERM

What kill signal to send to the worker

register(instance)

schedulers/base.js, line 38

Registers a worker with the scheduler

Name Type Description
instance object

The instance to register.