retry

package
v14.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWaitTimeout = wait.ErrWaitTimeout
)

Functions

func PollWithBackoff

func PollWithBackoff(ctx context.Context, cfg PollConfig, f PollWithBackoffCtxFunc) 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 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 PollWithBackoffCtxFunc added in v14.10.0

type PollWithBackoffCtxFunc func(ctx context.Context) (error, AttemptResult)

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

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