backoff

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package backoff provides exponential backoff calculation and context-aware sleep utilities.

Index

Constants

View Source
const (

	// MaxRetryAfterWait caps how long we'll honor a Retry-After header to prevent
	// a misbehaving server from blocking the agent for an unreasonable amount of time.
	MaxRetryAfterWait = 60 * time.Second
)

Configuration constants for exponential backoff.

Variables

This section is empty.

Functions

func Calculate

func Calculate(attempt int) time.Duration

Calculate returns the backoff duration for a given attempt (0-indexed). Uses exponential backoff with jitter.

func SleepWithContext

func SleepWithContext(ctx context.Context, d time.Duration) bool

SleepWithContext sleeps for the specified duration, returning early if context is cancelled. Returns true if the sleep completed, false if it was interrupted by context cancellation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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