Skip to content
do- edited this page Aug 29, 2024 · 12 revisions

Lag is a companion class to JobSource for setting an extra delay before creating a new Job.

Basically, this is an array of possible (strictly ascending) delay values, in milliseconds, from which the one is fetched, depending on the (severity) level, increasing with each botched job and reset to zero after the first success.

Constructor

const lag = new Lag ([0, 10, 100, Infinity])

The only parameter corresponds to the values property.`

Properties

Name Type Default Description
jobSource JobSource Write only property, the setter actually subscribes the Lag instance to the jobSource's events
level Number 0 The current lag level
values [Number] [0] Possible lag values

Methods

onFail ()

This method is registered with the jobSource's job-error event. In the base implementation, increases level by 1 unless it causes values oferflow, otherwise does nothing.

onSuccess ()

This method is registered with the jobSource's job-end and reset events. In the base implementation, resets level to 0.

valueOf ()

Overriding Object.prototype.valueOf(), returns values [level].

Clone this wiki locally