Documentation
¶
Index ¶
Constants ¶
View Source
const ( MinDelay = 1 * time.Second // Initial delay for retry interval. MaxInterval = 60 * time.Second // Maximum interval an individual retry may have. MaxElapsedTime = 0 * time.Second // Maximum time all retries may take. `0` corresponds to no limit on the time of the retries. RetryFactor float64 = 2 // Multiplier factor computed exponential retry interval is scaled by. NumRetries uint64 = 3 // Total number of retries attempted. MinDelayChain = 12 * time.Second // Initial delay for retry interval for contract calls. Corresponds to 1 ethereum block. MaxIntervalChain = 2 * time.Minute // Maximum interval for an individual retry. )
Variables ¶
This section is empty.
Functions ¶
func Retry ¶
func Retry(functionToRetry func() error, minDelay time.Duration, factor float64, maxTries uint64, maxInterval time.Duration, maxElapsedTime time.Duration) error
Retries a given function in an exponential backoff manner. It will retry calling the function while it returns an error, until the max retries. If maxTries == 0 then the retry function will run indefinitely until success from the configuration are reached, or until a `PermanentError` is returned. The function to be retried should return `PermanentError` when the condition for stop retrying is met.
Types ¶
type PermanentError ¶
type PermanentError struct {
Inner error
}
Note we use a custom Permanent error type for asserting Permanent Erros within the retry library. We do not implement an explicit Transient error type and operate under the assumption that all errors that are not Permanent are Transient.
func (PermanentError) Error ¶
func (e PermanentError) Error() string
func (PermanentError) Is ¶
func (e PermanentError) Is(err error) bool
func (PermanentError) Unwrap ¶
func (e PermanentError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.