time

package
v2.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

func RandomDelayWithJitter(ctx context.Context, baseDelay time.Duration)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL