retry

package
v17.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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. Context error 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

type PollConfig struct {
	Backoff  BackoffManager
	Interval time.Duration
	Sliding  bool
	// contains filtered or unexported fields
}

func (*PollConfig) Poke

func (c *PollConfig) Poke()

type PollConfigFactory

type PollConfigFactory func() PollConfig

func NewPollConfigFactory

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

type PollWithBackoffCtxFunc

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