Documentation
¶
Index ¶
- Constants
- func ConfirmWithTimeout(backoffTime time.Duration, backoffMax time.Duration, timeout time.Duration, ...) (bool, error)
- func ConfirmWithTimeoutDefaultBackoff(timeout time.Duration, confirmFn func(ctx context.Context) (bool, error)) (bool, error)
- func DoWithDefaultRetry(timeout time.Duration, doFn func(ctx context.Context) error) error
- func DoWithRetry(backoffTime time.Duration, backoffMax time.Duration, timeout time.Duration, ...) error
Constants ¶
const ( // DefaultDoBackoffTime is the default value of backoff time used by // DoWithDefaultRetry function. DefaultDoBackoffTime = 1 * time.Second // DefaultDoMaxBackoffTime is the default value of max backoff time used by // DoWithDefaultRetry function. DefaultDoMaxBackoffTime = 120 * time.Second )
const ( // DefaultConfirmBackoffTime is the default value of backoff time used by // ConfirmWithDefaultTimeout function. DefaultConfirmBackoffTime = 5 * time.Second // DefaultConfirmMaxBackoffTime is the default value of max backoff time // used by ConfirmWithDefaultTimeout function. DefaultConfirmMaxBackoffTime = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func ConfirmWithTimeout ¶
func ConfirmWithTimeout( backoffTime time.Duration, backoffMax time.Duration, timeout time.Duration, confirmFn func(ctx context.Context) (bool, error), ) (bool, error)
ConfirmWithTimeout executes the provided confirmFn until it returns true or until it fails or until a timeout is hit. It applies exponential backoff wait of backoffTime * 2^n before nth execution of confirmFn. In case the calculated backoff is longer than backoffMax, the backoffMax is applied. In case confirmFn returns an error, ConfirmWithTimeout exits with the same error immediately. This is different from DoWithRetry behavior as the use case for this function is different. ConfirmWithTimeout is intended to be used to confirm a chain state and not to try to enforce a successful execution of some function.
func ConfirmWithTimeoutDefaultBackoff ¶
func ConfirmWithTimeoutDefaultBackoff( timeout time.Duration, confirmFn func(ctx context.Context) (bool, error), ) (bool, error)
ConfirmWithTimeoutDefaultBackoff executed the provided confirmFn until it returns true or until it fails or until timeout is hit. It applies backoff wait of DefaultConfirmBackoffTime * 2^n before nth execution of confirmFn. In case the calculated backoff is longer than DefaultConfirmMaxBackoffTime, DefaultConfirmMaxBackoffTime is applied. In case confirmFn returns an error, ConfirmWithTimeoutDefaultBackoff exits with the same error immediately. This is different from DoWithDefaultRetry behavior as the use case for this function is different. ConfirmWithTimeoutDefaultBackoff is intended to be used to confirm a chain state and not to try to enforce a successful execution of some function.
func DoWithDefaultRetry ¶
DoWithDefaultRetry executes the provided doFn as long as it returns an error or until a timeout is hit. It applies exponential backoff wait of DefaultBackoffTime * 2^n before nth retry of doFn. In case the calculated backoff is longer than DefaultMaxBackoffTime, the DefaultMaxBackoffTime is applied.
func DoWithRetry ¶
func DoWithRetry( backoffTime time.Duration, backoffMax time.Duration, timeout time.Duration, doFn func(ctx context.Context) error, ) error
DoWithRetry executes the provided doFn as long as it returns an error or until a timeout is hit. It applies exponential backoff wait of backoffTime * 2^n before nth retry of doFn. In case the calculated backoff is longer than backoffMax, the backoffMax wait is applied.
Types ¶
This section is empty.