retry

package
v0.0.0-...-bb0df7c Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExponentialBackoffWithContext

func ExponentialBackoffWithContext(ctx context.Context, backoff wait.Backoff, condition ConditionWithContextFunc) error

ExponentialBackoffWithContext repeats a condition check with exponential backoff and stop repeating when the context passed to this function is done.

It checks the condition up to Steps times, increasing the wait by multiplying the previous duration by Factor.

If Jitter is greater than zero, a random amount of each duration is added (between duration and duration*(1+jitter)).

If the condition never returns true, ErrWaitTimeout is returned. All other errors terminate immediately.

func IsHTTPClientError

func IsHTTPClientError(err error) bool

IsHTTPClientError indicates whether the error passes is an 4xx API server error (client error).

func RetryOnConnectionErrors

func RetryOnConnectionErrors(ctx context.Context, fn ConditionWithContextFunc) error

RetryOnConnectionErrors will take context and condition function and retry the condition function until: 1) no error is returned 2) a client (4xx) HTTP error is returned 3) the context passed to the condition function is done 4) numbers of steps in the exponential backoff are met In case of 3) or 4) the error returned will be the last observed error from the condition function.

Types

type ConditionWithContextFunc

type ConditionWithContextFunc func(ctx context.Context) (done bool, err error)

ConditionWithContextFunc returns true if the condition is satisfied, or an error if the loop should be aborted. The context passed to condition function allow function body to return faster than context.Done().

Jump to

Keyboard shortcuts

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