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.
| get ShareUsageBackOff::backingOff |
( |
| ) |
|
|
inline |
True from the start of a pause until a send succeeds.
- Returns
- {boolean} whether sending is backing off
| 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 |
| 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
| 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
| ShareUsageBackOff::succeeded |
( |
| ) |
|
|
inline |
Records a successful send.
- Returns
- {boolean} true if this ended a back-off