retry

package
v0.0.0-...-a618dbc Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxAttempts = 10
	DefaultDelay       = time.Millisecond * 100
)

Variables

View Source
var (
	DefaultDoRetry = func(attempt int, err error) (time.Duration, bool) { return DefaultDelay, true }
)

Functions

func Do

func Do(retryable Retryable) error

func Go

func Go(do func() error, options ...Option) error

Types

type Option

type Option func(retryable *funcRetryable)

func WithDelay

func WithDelay(delay time.Duration) Option

func WithDoRetry

func WithDoRetry(doRetry func(error) bool) Option

func WithDoRetryWithDelay

func WithDoRetryWithDelay(doRetry func(int, error) (time.Duration, bool)) Option

func WithMaxAttempts

func WithMaxAttempts(maxAttempts int) Option

func WithOnRetry

func WithOnRetry(onRetry func(int, time.Duration, error)) Option

type Retryable

type Retryable interface {
	Do() error
}

func New

func New(do func() error, options ...Option) Retryable

type RetryableAttempts

type RetryableAttempts interface {
	Retryable
	MaxAttempts() int
}

type RetryableDoRetry

type RetryableDoRetry interface {
	Retryable
	DoRetry(err error) bool
}

type RetryableDoRetryWithDelay

type RetryableDoRetryWithDelay interface {
	Retryable
	DoRetry(attempt int, err error) (time.Duration, bool)
}

type RetryableOnRetry

type RetryableOnRetry interface {
	Retryable
	OnRetry(attempt int, wait time.Duration, err error)
}

Jump to

Keyboard shortcuts

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