retry

package
v0.0.0-...-9101f62 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStop = errors.New("stop retries")
)

Functions

func Do

func Do(fn RetryableFunc, opts Options) error

Types

type Delayer

type Delayer interface {
	Delay(startTime time.Time, attempts int, err error) time.Duration
}

func CombineDelayers

func CombineDelayers(combine func(ds []time.Duration) time.Duration, delayers ...Delayer) Delayer

func ExponentialBackoffDelayer

func ExponentialBackoffDelayer(coefficient int) Delayer

func FixedDelayer

func FixedDelayer(d time.Duration) Delayer

func LimitDelayer

func LimitDelayer(inner Delayer, limit time.Duration) Delayer

func LinearDelayer

func LinearDelayer(step time.Duration) Delayer

func MaxDelayer

func MaxDelayer(delayers ...Delayer) Delayer

func MinDelayer

func MinDelayer(delayers ...Delayer) Delayer

func RandomDelayer

func RandomDelayer(minDelay time.Duration, maxJitter time.Duration) Delayer

func SumDelayer

func SumDelayer(delayers ...Delayer) Delayer

type DelayerFunc

type DelayerFunc func(startTime time.Time, attempts int, err error) time.Duration

func (DelayerFunc) Delay

func (df DelayerFunc) Delay(startTime time.Time, attempts int, err error) time.Duration

type Options

type Options struct {
	Delayer Delayer
	Stopper Stopper
}

type RetryableFunc

type RetryableFunc func() error

type Stopper

type Stopper interface {
	Stop(startTime time.Time, attempts int, err error) bool
}

func AllStoppers

func AllStoppers(stoppers ...Stopper) Stopper

func AnyStopper

func AnyStopper(stoppers ...Stopper) Stopper

func DeadlineStopper

func DeadlineStopper(deadline time.Time) Stopper

func MaxAttemptsStopper

func MaxAttemptsStopper(maxAttempts int) Stopper

func TimeoutStopper

func TimeoutStopper(d time.Duration) Stopper

type StopperFunc

type StopperFunc func(startTime time.Time, attempts int, err error) bool

func (StopperFunc) Stop

func (sf StopperFunc) Stop(startTime time.Time, attempts int, err error) bool

Jump to

Keyboard shortcuts

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