retry

package
v1.1.68-test Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithExponentialBackoff

func WithExponentialBackoff(ctx context.Context, cfg Config, fn RetryableFunc) error

WithExponentialBackoff retries fn indefinitely with exponential backoff until: - fn returns done=true - ctx is cancelled

Types

type Config

type Config struct {
	InitialBackoff time.Duration // Starting backoff duration (default: 100ms)
	MaxBackoff     time.Duration // Maximum backoff duration (default: 30s)
	Multiplier     float64       // Backoff multiplier (default: 2.0)
}

Config holds retry configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible retry defaults

type RetryableFunc

type RetryableFunc func() (done bool, err error)

RetryableFunc is a function that returns (done bool, err error) done=true means success, stop retrying done=false with nil error means retry done=false with error means retry (error is logged)

Jump to

Keyboard shortcuts

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