retry

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBackoffBase = time.Nanosecond
	MaxBackoff         = math.MaxInt64
)

Variables

View Source
var ErrBackoffExhausted = errors.New("retry attempts exhausted")

Functions

This section is empty.

Types

type BackoffProvider

type BackoffProvider interface {
	BackoffByAttempt(attempts int) (time.Duration, error)
}

type ExponentialJitterBackoff

type ExponentialJitterBackoff struct {
	Base        time.Duration // Base backoff duration
	Cap         time.Duration // The maximum backoff time generated
	MaxAttempts int           // If set will throw ErrBackoffExhausted if reached

	JitterSource io.Reader //
}

ExponentialJitterBackoff provides an exponentially growing backoff duration with jitter to discourage the thundering herd problem.

BackoffByAttempt will return `random_between(0, min(cap, base * 2 ** attempts))`

This is the "Full Jitter" algorithm described at https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

func (*ExponentialJitterBackoff) BackoffByAttempt

func (provider *ExponentialJitterBackoff) BackoffByAttempt(attempts int) (time.Duration, error)

Jump to

Keyboard shortcuts

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