51Degrees Pipeline for Node.js

ShareUsageBackOff Class Reference

Detailed Description

Decides when usage sharing may send.

Sending pauses for the initial delay once the set number of sends fail within the window. A failed send after a pause multiplies the delay, up to the maximum, and a successful send ends the back-off. Only sending pauses, so evidence is still queued while paused. Each method takes the time from the caller, in milliseconds on the clock that now() reads, so a change to the system time cannot lengthen or skip a pause.

Public Member Functions

 constructor ({ failuresToEnterRecovery=10, failuresWindowSeconds=100, initialRecoveryDelaySeconds=2.0, maxRecoveryDelaySeconds=300.0, recoveryMultiplier=2.0 }={})
 Constructor for ShareUsageBackOff.
get backingOff ()
 True from the start of a pause until a send succeeds.
 remaining (now)
 The time left before sending may start again.
 failed (now)
 Records a failed send.
 succeeded ()
 Records a successful send.

Static Public Member Functions

static now ()
 The time in milliseconds on a monotonic clock, for the caller to pass to the other methods.

Member Function Documentation

◆ backingOff()

get ShareUsageBackOff::backingOff ( )
inline

True from the start of a pause until a send succeeds.

Returns
{boolean} whether sending is backing off

◆ constructor()

ShareUsageBackOff::constructor ( { failuresToEnterRecovery=10, failuresWindowSeconds=100, initialRecoveryDelaySeconds=2.0, maxRecoveryDelaySeconds=300.0, recoveryMultiplier=2.0 } = {})
inline

Constructor for ShareUsageBackOff.

Parameters
{object}options settings for the back-off
{number}options.failuresToEnterRecovery the number of failed sends within the failures window that pauses sending, from 1 to 100
{number}options.failuresWindowSeconds the time in seconds over which failed sends are counted
{number}options.initialRecoveryDelaySeconds the length in seconds of the first pause
{number}options.maxRecoveryDelaySeconds the longest a pause can be, in seconds
{number}options.recoveryMultiplier what the pause is multiplied by each time the send tried when a pause ends fails

◆ failed()

ShareUsageBackOff::failed ( now)
inline

Records a failed send.

Parameters
{number}now the time now in milliseconds
Returns
{number} the new pause in milliseconds if this failure started or lengthened one, otherwise zero

◆ now()

ShareUsageBackOff::now ( )
inlinestatic

The time in milliseconds on a monotonic clock, for the caller to pass to the other methods.

Its zero is not a calendar time.

Returns
{number} the milliseconds

◆ remaining()

ShareUsageBackOff::remaining ( now)
inline

The time left before sending may start again.

Parameters
{number}now the time now in milliseconds
Returns
{number} the milliseconds left, or zero if sending may start now

◆ succeeded()

ShareUsageBackOff::succeeded ( )
inline

Records a successful send.

Returns
{boolean} true if this ended a back-off