Documentation ¶
Index ¶
- func NewUnlimitedExponentialBackoff() libbackoff.BackOff
- func Retry(ctx context.Context, fn func() error) error
- func RetryWithInterval(ctx context.Context, interval libbackoff.BackOff, fn func() error, ...) error
- func Sleep(ctx context.Context, d time.Duration)
- type AbortRetry
- type ContinueRetry
- type Retryer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewUnlimitedExponentialBackoff ¶
func NewUnlimitedExponentialBackoff() libbackoff.BackOff
NewUnlimitedExponentialBackoff returns a new exponential backoff interval without time limit
func Retry ¶
Retry attempts to execute fn with default delay retrying it for a default number of attempts. fn can return AbortRetry to abort or ContinueRetry to continue the execution.
func RetryWithInterval ¶
func RetryWithInterval(ctx context.Context, interval libbackoff.BackOff, fn func() error, logger log.FieldLogger) error
RetryWithInterval retries the specified operation fn using the specified backoff interval
Types ¶
type AbortRetry ¶
type AbortRetry struct {
Err error
}
AbortRetry if returned from Retry, will lead to retries to be stopped, but the Retry function will return internal Error
func (AbortRetry) Error ¶
func (r AbortRetry) Error() string
type ContinueRetry ¶
type ContinueRetry struct {
Message string
}
ContinueRetry if returned from Retry, will be lead to retry next time
func Continue ¶
func Continue(format string, args ...interface{}) ContinueRetry
Continue causes Retry function to continue trying and logging message
func (ContinueRetry) Error ¶
func (r ContinueRetry) Error() string
type Retryer ¶
type Retryer struct { // Delay specifies the interval between retry attempts Delay time.Duration // Attempts specifies the number of attempts to execute before failing. // Should be >= 1, zero value is not useful Attempts int // FieldLogger specifies the log sink log.FieldLogger }
Retryer is a process that can retry a function