backoff

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package backoff provides backoff calculation functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExponentialBackoffConfig

type ExponentialBackoffConfig struct {
	Base       time.Duration
	Cap        time.Duration
	Multiplier float64
}

ExponentialBackoffConfig is the configuration for exponential backoff.

type Func

type Func func(attempts int, resp *http.Response) time.Duration

Func generates backoff delays.

func ExponentialBackoff

func ExponentialBackoff(cfg ExponentialBackoffConfig) Func

ExponentialBackoff returns an exponential backoff with partial jitter.

func RateLimitedExponentialBackoff

func RateLimitedExponentialBackoff(cfg ExponentialBackoffConfig) Func

RateLimitedExponentialBackoff returns an backoff function that prioritizes `Retry-After` headers, defaulting to exponential backoff if they're not found. Adds partial jitter.

Jump to

Keyboard shortcuts

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