backoff

package
v0.0.0-...-d2b1cdf Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRetry

func CheckRetry(r Retrier) bool

CheckRetry checks if retry is allowed, and if it is allowed, it will sleep for the backoff duration. It is used when the function to be retried takes in arguments or returns a result.

func Retry

func Retry(f Retryable, p RetryPolicy, isRetryable IsErrorRetryable) error

Retry will retry the given function until it succeeded or hit maximum number of retries then return last error.

Types

type IsErrorRetryable

type IsErrorRetryable func(error) bool

IsErrorRetryable could be used to exclude certain errors during retry

type Retrier

type Retrier interface {
	NextBackOff() time.Duration
}

Retrier is interface for managing backoff.

func NewRetrier

func NewRetrier(policy RetryPolicy) Retrier

NewRetrier is used for creating a new instance of Retrier

type RetryPolicy

type RetryPolicy interface {
	CalculateNextDelay(attempts int) time.Duration
}

RetryPolicy is interface for defining retry policy.

func NewRetryPolicy

func NewRetryPolicy(maxAttempts int, retryInterval time.Duration) RetryPolicy

NewRetryPolicy is used to create a new instance or RetryPolicy.

type Retryable

type Retryable func() error

Retryable is a function returning an error which can be retried.

Jump to

Keyboard shortcuts

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