retry

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInitialInterval = 500 * time.Millisecond
	DefaultMaxRetries      = 100
	DefaultMaxInterval     = 60 * time.Second

	DefaultMultiplier          float64 = 1.5
	DefaultRandomizationFactor float64 = 0.5
)
View Source
const (
	CannotBeRetried    = "this operation cannot be retried"
	MaxRetriesExceeded = "this operation exceeded the maximum number of retries"
	MaxElapsedExceeded = "this operation exceeded the maximum time allowed to complete"
)

Variables

This section is empty.

Functions

func DoNotRetry

func DoNotRetry(err error) error

Types

type Backoff

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

func NewBackoff

func NewBackoff(options ...BackoffOption) *Backoff

func NewConstantBackoff

func NewConstantBackoff(options ...BackoffOption) *Backoff

func NewExponentialBackoff

func NewExponentialBackoff(options ...BackoffOption) *Backoff

func (Backoff) Retry

func (b Backoff) Retry(ctx context.Context, fn func() error) error

type BackoffOption

type BackoffOption func(*Backoff)

func WithBackoffInitialInterval

func WithBackoffInitialInterval(initialInterval time.Duration) BackoffOption

func WithBackoffMaxInterval

func WithBackoffMaxInterval(maxInterval time.Duration) BackoffOption

func WithBackoffMaxRetries

func WithBackoffMaxRetries(maxRetries int) BackoffOption

func WithBackoffMultiplier

func WithBackoffMultiplier(multiplier float64) BackoffOption

func WithBackoffRandomizationFactor

func WithBackoffRandomizationFactor(randomizationFactor float64) BackoffOption

type ErrDoNotRetry

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

func (*ErrDoNotRetry) Error

func (e *ErrDoNotRetry) Error() string

func (*ErrDoNotRetry) Unwrap

func (e *ErrDoNotRetry) Unwrap() error

type Retryer

type Retryer interface {
	Retry(ctx context.Context, fn func() error) error
}

Jump to

Keyboard shortcuts

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