retry

package
v1.50.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJitter

func AddJitter(duration time.Duration, jitter time.Duration) time.Duration

AddJitter adds an amount of jitter between 0 and the given jitter to the given duration

func RetryNWithBackoff

func RetryNWithBackoff(backoff Backoff, n int, fn func() error) error

RetryNWithBackoff takes a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until either it does not return an error or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.

func RetryNWithBackoffCtx

func RetryNWithBackoffCtx(ctx context.Context, backoff Backoff, n int, fn func() error) error

RetryNWithBackoffCtx takes a context, a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until it does not return an error, the context is done, or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.

func RetryWithBackoff

func RetryWithBackoff(backoff Backoff, fn func() error) error

RetryWithBackoff takes a Backoff and a function to call that returns an error If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried

func RetryWithBackoffCtx

func RetryWithBackoffCtx(ctx context.Context, backoff Backoff, fn func() error) error

RetryWithBackoffCtx takes a context, a Backoff, and a function to call that returns an error If the context is done, nil will be returned If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried

Types

type Backoff

type Backoff interface {
	Reset()
	Duration() time.Duration
}

type ExponentialBackoff

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

func NewExponentialBackoff

func NewExponentialBackoff(min, max time.Duration, jitterMultiple, multiple float64) *ExponentialBackoff

func (*ExponentialBackoff) Duration

func (sb *ExponentialBackoff) Duration() time.Duration

func (*ExponentialBackoff) Reset

func (sb *ExponentialBackoff) Reset()

Directories

Path Synopsis
Package mock_retry is a generated GoMock package.
Package mock_retry is a generated GoMock package.

Jump to

Keyboard shortcuts

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