retry

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxElapsedTime = errors.New("maximal elapsed time reached")

ErrMaxElapsedTime is returned when the maximal elapsed time is reached

View Source
var ErrMaxRetryAttempts = errors.New("maximal number of retry attempts reached")

ErrMaxRetryAttempts is returned when the number of maximal retry attempts is reached

Functions

This section is empty.

Types

type ExponentialBackoff

type ExponentialBackoff struct {
	// If Ctx is canceled, the retry method will terminate early with the
	// error from Ctx.Err().
	Ctx context.Context

	// InitialDelayInterval represents the initial amount of time of sleep
	InitialDelayInterval time.Duration

	// MaxDelayInterval represents the maximal amount of time of sleep between
	// retries
	MaxDelayInterval time.Duration

	// MaxElapsedTime represents the maximal amount of time allowed to retry. A
	// value of zero signifies no limit
	MaxElapsedTime time.Duration

	// MaxRetryAttempts is the maximal number of retries before exiting with
	// an error. A value of zero signifies unlimited retry attemps
	MaxRetryAttempts int

	// Multiplier is used to increment the current interval by multiplying it with
	// this multiplier
	Multiplier float64
	// contains filtered or unexported fields
}

ExponentialBackoff contains the configuration for exponential backoff

func (*ExponentialBackoff) Retry

func (b *ExponentialBackoff) Retry(fn Func) error

Retry retries the provided func with exponential backoff, until the maximal number of retries is reached

type Func

type Func func(retry int) (done bool, err error)

Func represents a function to retry, which returns true if the attempt is successful, or an error if the retry should be aborted

Jump to

Keyboard shortcuts

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