retry

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 3 Imported by: 0

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