retry

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

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

func DoWithData

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

Types

type Backoff

type Backoff struct {
	// How long to wait before first retry
	InitialDelay time.Duration
	// Upper bound on backoff
	MaxDelay time.Duration
	// Factor with which to multiply backoff after a failed retry
	Factor float64
	// By how much to randomize backoff
	Jitter float64
}

func (*Backoff) Delay

func (b *Backoff) Delay(attempt int) time.Duration

type Config

type Config struct {
	// contains filtered or unexported fields
}

type ContextValues

type ContextValues struct {
	Attempt int
	Delay   time.Duration
}

type ContextValuesKey

type ContextValuesKey string

type Option

type Option func(*Config) error

func MaxAttempts

func MaxAttempts(n int) Option

func RetryIf

func RetryIf(fn func(error) bool) Option

func WithBackoff

func WithBackoff(b Backoff) Option

func WithContext

func WithContext(ctx context.Context) Option

Jump to

Keyboard shortcuts

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