retry

package
v14.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWaitTimeout = wait.ErrWaitTimeout
)

Functions

func PollImmediateUntil

func PollImmediateUntil(ctx context.Context, interval time.Duration, f ConditionFunc) error

PollImmediateUntil is a wrapper to make the function more convenient to use. - ctx is used instead of a channel. - ctx is the first argument to follow the convention. - condition is the last argument because code is more readable this way when used with inline functions.

func PollWithBackoff

func PollWithBackoff(ctx context.Context, cfg PollConfig, f PollWithBackoffFunc) error

PollWithBackoff runs f every duration given by BackoffManager.

If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f. It returns when: - context signals done. ErrWaitTimeout is returned in this case. - f returns Done

Types

type AttemptResult

type AttemptResult int
const (
	// Continue means there was no error and polling can continue normally.
	Continue AttemptResult = iota
	// ContinueImmediately means there was no error and polling can continue normally.
	ContinueImmediately
	// Backoff means there was a retriable error, so the caller should try later.
	Backoff
	// Done means the polling should stop. There may or may not have been an error.
	Done
)

type BackoffManager

type BackoffManager = wait.BackoffManager

type BackoffManagerFactory

type BackoffManagerFactory func() BackoffManager

func NewExponentialBackoffFactory

func NewExponentialBackoffFactory(initBackoff, maxBackoff, resetDuration time.Duration, backoffFactor, jitter float64) BackoffManagerFactory

type ConditionFunc

type ConditionFunc = wait.ConditionFunc

type PollConfig added in v14.2.0

type PollConfig struct {
	Backoff  BackoffManager
	Interval time.Duration
	Sliding  bool
}

type PollConfigFactory added in v14.2.0

type PollConfigFactory func() PollConfig

func NewPollConfigFactory added in v14.2.0

func NewPollConfigFactory(interval time.Duration, backoff BackoffManagerFactory) PollConfigFactory

type PollWithBackoffFunc

type PollWithBackoffFunc func() (error, AttemptResult)

PollWithBackoffFunc is a function that is called to perform polling. Signature is unusual because AttemptResult must be checked, not the error.

Jump to

Keyboard shortcuts

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