Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExponentialDelayWithJitter ¶ added in v2.3.4
func ExponentialDelayWithJitter(ctx context.Context, attempt uint, baseDelay, maxDelay time.Duration)
ExponentialDelayWithJitter is an exponential backoff strategy with jitter for retries. It calculates delay based on the attempt number, adds jitter, and sleeps for that duration, capped at maxDelay.
func RandomDelayWithJitter ¶ added in v2.4.0
RandomDelayWithJitter sleeps for a duration within ±25% of baseDelay to add jitter. This helps prevent thundering herd when multiple clients retry simultaneously. Example: baseDelay=2s results in sleep time between [1.5s, 2.5s). It returns early if the context is canceled.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.