retry

package
v0.0.0-...-f4dd3ec Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StandardConfig = &Config{
	Attempts:  5,
	Delay:     1 * time.Second,
	MaxDelay:  10 * time.Second,
	MaxJitter: 1.1,
	Context:   context.Background(),
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Attempts    uint
	Delay       time.Duration
	MaxDelay    time.Duration
	MaxJitter   float64
	OnRetry     func(uint, error) error
	RetryIf     func(error) bool
	ExposeDelay func(n uint, err error) time.Duration
	Context     context.Context
}

type Retry

type Retry struct {
	*Config
}

func NewRetry

func NewRetry(config *Config) *Retry

func (*Retry) Do

func (r *Retry) Do(doFunc func() error) error

func (*Retry) WithAttempts

func (r *Retry) WithAttempts(n uint) *Retry

func (*Retry) WithContext

func (r *Retry) WithContext(ctx context.Context) *Retry

func (*Retry) WithDelay

func (r *Retry) WithDelay(d time.Duration) *Retry

func (*Retry) WithDelayType

func (r *Retry) WithDelayType(t func(n uint, err error) time.Duration) *Retry

func (*Retry) WithMaxDelay

func (r *Retry) WithMaxDelay(d time.Duration) *Retry

func (*Retry) WithMaxJitter

func (r *Retry) WithMaxJitter(d float64) *Retry

func (*Retry) WithOnRetry

func (r *Retry) WithOnRetry(onRetry func(uint, error) error) *Retry

func (*Retry) WithRetryIf

func (r *Retry) WithRetryIf(f func(error) bool) *Retry

Jump to

Keyboard shortcuts

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