retry

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BudgetExceeded = errors.New("retry: budget exceeded")

Functions

func Do added in v0.5.0

func Do(cfg Config, fn func() error) error

func DoBudget added in v0.19.0

func DoBudget(b Budget, cfg Config, fn func() error) error

func DoCtx added in v0.5.0

func DoCtx(h ctxpkg.Handle, cfg Config, fn func(ctxpkg.Handle) error) error

func Open added in v0.19.0

func Open(b Budget) bool

func Sleep

func Sleep(cfg Config, attempt int)

Types

type Budget added in v0.19.0

type Budget struct {
	Key         string
	MaxFailures int
	Window      time.Duration
	// contains filtered or unexported fields
}

func NewBudget added in v0.19.0

func NewBudget() Budget

func WithKey added in v0.19.0

func WithKey(b Budget, key string) Budget

func WithLimit added in v0.19.0

func WithLimit(b Budget, maxFailures int, window time.Duration) Budget

type Config

type Config struct {
	MaxAttempts  int
	InitialDelay int
	Strategy     Strategy
}

func Attempts

func Attempts(cfg Config, maxAttempts int) Config

func Delay

func Delay(cfg Config, delayMs int) Config

func Exponential added in v0.5.0

func Exponential(cfg Config) Config

func Linear

func Linear(cfg Config) Config

func New

func New() Config

type Strategy added in v0.5.0

type Strategy string
const (
	StrategyLinear      Strategy = "linear"
	StrategyExponential Strategy = "exponential"
)

func ParseStrategy added in v0.13.1

func ParseStrategy(s string) (Strategy, bool)

func (Strategy) String added in v0.5.0

func (e Strategy) String() string

Jump to

Keyboard shortcuts

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