retry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: AGPL-3.0 Imports: 4 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlwaysRetryFunc = func(err error) bool {
	return true
}

AlwaysRetryFunc returns always true and thus indicates that always should be tried until the retrier hits its limit.

View Source
var TestableRetryFunc = func(err error) bool {
	_, ok := err.(*TestableRetrierError)
	return ok
}

TestableRetryFunc returns true if the returned error is a testableRetrierError and indicates that an action should be tried until the retrier hits its limit.

Functions

func OnConflict

func OnConflict(fn func() error) error

OnConflict provides a K8s-way "retrier" mechanism to avoid conflicts on resource updates.

func OnError

func OnError(maxTries int, retriable func(error) bool, workload func() error) error

OnError provides a K8s-way "retrier" mechanism. The value from retriable is used to indicate if workload should retried another time. Please see AlwaysRetryFunc() if a workload should always retried until a fixed threshold is reached.

func OnErrorWithLimit

func OnErrorWithLimit(limit time.Duration, retriable func(error) bool, workload func() error) error

OnErrorWithLimit provides a K8s-way "retrier" mechanism with a time limit as option.

Types

type TestableRetrierError

type TestableRetrierError struct {
	Err error
}

TestableRetrierError marks errors that indicate that a previously executed action should be retried with again. It must wrap an existing error.

func (*TestableRetrierError) Error

func (tre *TestableRetrierError) Error() string

Error returns the error's string representation.

Jump to

Keyboard shortcuts

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