Documentation
¶
Overview ¶
Package jitter provides functionality for adding random variation (jitter) to time durations.
This package is designed to help distributed systems avoid "thundering herd" problems by desynchronizing retry attempts or periodic jobs.
The jitter implementation is "subtractive". It calculates a duration randomly chosen between [d * (1 - p), d], where p is the jitter percentage. This ensures that the returned duration never exceeds the input duration, allowing strict adherence to maximum delay limits (e.g., in backoff strategies).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Jitter ¶
type Jitter struct {
// contains filtered or unexported fields
}
Jitter applies subtractive random jitter to a duration.
func New ¶
New creates a new Jitter instance with the given percentage p (0.0 to 1.0) and source of randomness r.
If r is nil, a default thread-safe, seeded generator is used.