retry

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAbort     = errors.New("retry loop aborted")
	ErrExhausted = errors.New("retry tries exhaused")
)

Functions

func Retry

func Retry(ctx context.Context, fn func(ctx context.Context) error, opts ...Option) error

func RetryValue

func RetryValue[T any](ctx context.Context, fn func(ctx context.Context) (T, error), opts ...Option) (T, error)

Types

type Option

type Option func(*RetryOptions)

func WithBackoffFactor

func WithBackoffFactor(factor float64) Option

func WithDelay

func WithDelay(delay time.Duration) Option

func WithJitter

func WithJitter(factorFn func() float64) Option

func WithMaxDelay

func WithMaxDelay(delay time.Duration) Option

func WithMaxTries

func WithMaxTries(tries int) Option

type RetryOptions

type RetryOptions struct {
	MaxTries      int
	Delay         time.Duration
	MaxDelay      time.Duration
	BackoffFactor float64
	Jitter        bool
	Rand          func() float64
}

func DefaultRetryOptions

func DefaultRetryOptions() RetryOptions

Jump to

Keyboard shortcuts

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