retry

package
v0.0.0-...-2b7dcb4 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RetryOnAnyError = func(error) bool { return true }

Functions

func RetryWhenErrorTypeMatches

func RetryWhenErrorTypeMatches(errorTypes []reflect.Type) func(error) bool

Types

type BackOffOpts

type BackOffOpts struct {
	InitialInterval time.Duration
	MaxInterval     time.Duration
	MaxElapsedTime  time.Duration
}
var DefaultBackOffOpts *BackOffOpts = &BackOffOpts{
	InitialInterval: 500 * time.Millisecond,
	MaxInterval:     3 * time.Second,
	MaxElapsedTime:  10 * time.Second}

type Retrier

type Retrier struct {
	Name string
	// contains filtered or unexported fields
}

func New

func New(name string,
	backOffOpts *BackOffOpts, shouldRetryFunc func(error) bool) *Retrier

Retrier without logging functions included as defaults for notify funcs

func NewErrorTypeRetrier

func NewErrorTypeRetrier(name string,
	backOffOpts *BackOffOpts, errorTypes ...interface{}) *Retrier

func NewRetrier

func NewRetrier(name string,
	backOffOpts *BackOffOpts, shouldRetryFunc func(error) bool) *Retrier

func (*Retrier) AddNotifyGaveUp

func (r *Retrier) AddNotifyGaveUp(f RetryNotifier)

func (*Retrier) AddNotifyRetry

func (r *Retrier) AddNotifyRetry(f RetryNotifier)

func (*Retrier) Retry

func (r *Retrier) Retry(f func() (interface{}, error)) (interface{}, error)

func (*Retrier) SetBackOffOpts

func (r *Retrier) SetBackOffOpts(b *BackOffOpts)

type RetryEvent

type RetryEvent struct {
	Retrier  *Retrier
	Err      error
	NumTries int
}

type RetryNotifier

type RetryNotifier func(*RetryEvent)

Jump to

Keyboard shortcuts

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