retry

package
v0.157.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstantBackoff

type ConstantBackoff struct {
	MaxRetries int
	Time       int
	TimeUnit   time.Duration
	// contains filtered or unexported fields
}

ConstantBackoff defines a retry policy in which in we retry up to the provided maximum number of retries (MaxRetries). The duration is constant and always the one provided, i.e. Time converted to TimeUnit.

func (ConstantBackoff) Clone

func (b ConstantBackoff) Clone() Policy

Clone implements retry.Policy#Clone() retry.Policy.

func (ConstantBackoff) Done

func (b ConstantBackoff) Done() bool

Done implements retry.Policy#Done() bool.

func (*ConstantBackoff) Duration

func (b *ConstantBackoff) Duration() time.Duration

Duration implements retry.Policy#Duration() time.Duration.

func (*ConstantBackoff) Reset

func (b *ConstantBackoff) Reset()

Reset implements retry.Policy#Reset().

type ExponentialBackoff

type ExponentialBackoff struct {
	MaxRetries int
	TimeUnit   time.Duration
	// contains filtered or unexported fields
}

ExponentialBackoff defines a retry policy in which in we exponentially retry up to the provided maximum number of retries (MaxRetries).

func (ExponentialBackoff) Clone

func (b ExponentialBackoff) Clone() Policy

Clone implements retry.Policy#Clone() retry.Policy.

func (ExponentialBackoff) Done

func (b ExponentialBackoff) Done() bool

Done implements retry.Policy#Done() bool.

func (*ExponentialBackoff) Duration

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

Duration implements retry.Policy#Duration() time.Duration.

func (*ExponentialBackoff) Reset

func (b *ExponentialBackoff) Reset()

Reset implements retry.Policy#Reset().

type Policy

type Policy interface {
	Done() bool
	Duration() time.Duration
	Reset()
	Clone() Policy
}

Policy defines an "iterator"-style of interface for retry policies. The client should repeatedly call Done() and Duration() such that if Done() returns false, then Duration() is called, and the value returned should be the time to wait for before retrying an operation defined by the client. Once Done() returns true, the client should stop using the retry policy and "give up" in an appropriate manner for its use-case. Reset() resets the current policy's state, so that it can be re-used. Clone() clones the current policy, so that it can be used in a different thread/go-routine.

type TimingOutExponentialBackoff

type TimingOutExponentialBackoff struct {
	Timeout  time.Duration
	TimeUnit time.Duration
	// contains filtered or unexported fields
}

TimingOutExponentialBackoff defines a retry policy in which we exponentially retry up to the provided maximum duration (Timeout).

func NewTimingOutExponentialBackoff

func NewTimingOutExponentialBackoff(timeout time.Duration) TimingOutExponentialBackoff

NewTimingOutExponentialBackoff creates a new TimingOutExponentialBackoff with seconds as TimeUnit

func (TimingOutExponentialBackoff) Clone

Clone implements retry.Policy#Clone() retry.Policy.

func (TimingOutExponentialBackoff) Done

Done implements retry.Policy#Done() bool.

func (*TimingOutExponentialBackoff) Duration

Duration implements retry.Policy#Duration() time.Duration.

func (*TimingOutExponentialBackoff) Reset

func (b *TimingOutExponentialBackoff) Reset()

Reset implements retry.Policy#Reset().

Jump to

Keyboard shortcuts

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