package
0.0.0-20241226145920-483c662f7ff1
Repository: https://github.com/pingooio/stdx.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# Functions

Attempts set count of retry.
BackOffDelay is a DelayType which increases delay between consecutive retries.
CombineDelay is a DelayType the combines all of the specified delays into a new DelayTypeFunc.
Context allow to set context of retry default are Background context example of immediately cancellation (maybe it isn't the best example, but it describes behavior enough; I hope) ctx, cancel := context.WithCancel(context.Background()) cancel() retry.Do( func() error { ..
Delay set delay between retry default is 100ms.
DelayType set type of the delay between retries default is BackOff.
No description provided by the author
FixedDelay is a DelayType which keeps delay the same through all iterations.
IsRecoverable checks if error is an instance of `unrecoverableError`.
return the direct last error that came from the retried function default is false (return wrapped errors with everything).
MaxDelay set maximum delay between retry does not apply by default.
MaxJitter sets the maximum random Jitter between retries for RandomDelay.
OnRetry function callback are called each retry log each retry example: retry.Do( func() error { return errors.New("some error") }, retry.OnRetry(func(n uint, err error) { log.Printf("#%d: %s\n", n, err) }), ).
RandomDelay is a DelayType which picks a random delay up to config.maxJitter.
RetryIf controls whether a retry should be attempted after an error (assuming there are any retry attempts remaining) skip retry if special error example: retry.Do( func() error { return errors.New("special error") }, retry.RetryIf(func(err error) bool { if err.Error() == "special error" { return false } return true }) ) By default RetryIf stops execution if the error is wrapped using `retry.Unrecoverable`, so above example may also be shortened to: retry.Do( func() error { return retry.Unrecoverable(errors.New("special error")) } ).
Unrecoverable wraps an error in `unrecoverableError` struct.

# Structs

No description provided by the author

# Type aliases

DelayTypeFunc is called to return the next delay to wait after the retriable function fails on `err` after `n` attempts.
Error type represents list of errors in retry.
Function signature of OnRetry function n = count of attempts.
Option represents an option for retry.
Function signature of retryable function.
Function signature of retry if function.