folly::observer::withJitter

The returned Observer will proxy updates from the input observer but will delay the propagation of each update by some duration between 0 ms and lag + jitter. In addition, if an update arrives while no preceding jittered updates are still in flight, then the delay applied to the latest update will be a uniformly random duration between lag - jitter and lag + jitter.

Synopsis

Declared in <folly/observer/WithJitter.h>

template<typename T>
Observer<T>
withJitter(
    Observer<T> observer,
    std::chrono::milliseconds lag,
    std::chrono::milliseconds jitter);

Return Value

An Observer that proxies updates with jittered delays.

Parameters

NameDescription
observerThe input observer whose updates are proxied.
lagThe base delay applied to each propagated update.
jitterThe random spread added to or subtracted from the lag.