retry

package
v1.10.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const Stop time.Duration = -1

Stop indicates that no more retries should be made.

Variables

This section is empty.

Functions

func Permanent

func Permanent(err error) *backoff.PermanentError

Permanent wraps the given err in a *backoff.PermanentError. This error interrupts further retries and causes retrying mechanism.

func WithNotify

func WithNotify(ctx context.Context, op Operation, b Backoff, n Notify) error

WithNotify calls notify function with the error and wait duration for each failed attempt before sleep.

Types

type Backoff

type Backoff = backoff.BackOff

Backoff specifies a policy for how long to wait between retries. It is called after a failing request, to determine the amount of time that should pass before trying again.

func NewExponentialBackoff

func NewExponentialBackoff(initialInterval, maxElapsedTime, maxInterval time.Duration, multiplier, randomizationFactor float64) Backoff

NewExponentialBackoff returns Backoff implementation that increases each wait period exponentially. Multiplier controls how fast each wait period grows, and randomizationFactor allows to inject some jitter between periods.

func WithMaxRetries

func WithMaxRetries(b Backoff, maxRetries uint64) Backoff

WithMaxRetries allows to set maximum number of retries for given backoff strategy.

type BackoffFunc

type BackoffFunc func() time.Duration

BackoffFunc type is an adapter to allow the use of ordinary functions as Backoff.

func (BackoffFunc) Clone

func (b BackoffFunc) Clone() Backoff

Clone returns a copy of BackoffFunc.

func (BackoffFunc) NextBackOff

func (b BackoffFunc) NextBackOff() time.Duration

NextBackOff returns the duration to wait before retrying the operation.

func (BackoffFunc) Reset

func (b BackoffFunc) Reset()

Reset to initial state.

type Notify

type Notify = backoff.Notify

Notify is a notify-on-error function. It receives an operation error and backoff delay if the operation failed (with an error).

type Operation

type Operation = backoff.Operation

An Operation is executing by WithNotify(). The operation will be retried using a backoff policy if it returns an error.

Jump to

Keyboard shortcuts

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