poll

package
v0.113.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAlwaysRetryable

func IsAlwaysRetryable(error) bool

IsAlwaysRetryable instructs WaitWithRetries to retry until time expires.

func IsNeverRetryable

func IsNeverRetryable(error) bool

IsNeverRetryable instructs WaitWithRetries not to retry.

func Wait

func Wait(ctx context.Context, f Func) error

Wait calls WaitWithBackoff with default backoff parameters. The defaults are handled by the "github.com/jpillora/backoff" and are:

min = 100 * time.Millisecond
max = 10 * time.Second
factor = 2
jitter = false

func WaitWithBackoff

func WaitWithBackoff(ctx context.Context, b backoff.Backoff, f Func) error

WaitWithBackoff calls a function until it returns true, an error, or until the context is done.

func WaitWithBackoffWithRetries

func WaitWithBackoffWithRetries(ctx context.Context, b backoff.Backoff, numRetries int, r IsRetryableFunc, f Func) error

WaitWithBackoffWithRetries will invoke a function `f` until it returns true or the context `ctx` is done. If `f` returns an error, WaitWithBackoffWith retries will tolerate up to `numRetries` errors. If returned error is not retriable according to `r`, then it will bait out immediately. The wait time between retries will be decided by backoff parameters `b`.

func WaitWithRetries

func WaitWithRetries(ctx context.Context, numRetries int, r IsRetryableFunc, f Func) error

WaitWithRetries will invoke a function `f` until it returns true or the context `ctx` is done. If `f` returns an error, WaitWithRetries will tolerate up to `numRetries` errors.

Types

type Func

type Func func(context.Context) (bool, error)

Func returns true if the condition is satisfied, or an error if the loop should be aborted.

type IsRetryableFunc

type IsRetryableFunc func(error) bool

IsRetryableFunc is the signature for functions that return true if we should retry an error

Jump to

Keyboard shortcuts

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