Documentation ¶
Index ¶
Constants ¶
const ( NetworkInitialInterval = 1 * time.Second // Initial delay for retry interval. NetworkMaxInterval = 60 * time.Second // Maximum interval an individual retry may have. NetworkMaxElapsedTime = 0 * time.Second // Maximum time all retries may take. `0` corresponds to no limit on the time of the retries. NetworkRandomizationFactor float64 = 0 // Randomization (Jitter) factor used to map retry interval to a range of values around the computed interval. In precise terms (random value in range [1 - randomizationfactor, 1 + randomizationfactor]). NOTE: This is set to 0 as we do not use jitter in Aligned. NetworkMultiplier float64 = 2 // Multiplier factor computed exponential retry interval is scaled by. NetworkNumRetries uint64 = 3 // Total number of retries attempted. // Retry Params for Sending Tx to Chain ChainInitialInterval = 12 * time.Second // Initial delay for retry interval for contract calls. Corresponds to 1 ethereum block. ChainMaxInterval = 2 * time.Minute // Maximum interval for an individual retry. // Retry Params for WaitForTransactionReceipt in the Fee Bump WaitForTxMaxInterval = 2 * time.Second // Maximum interval for an individual retry. WaitForTxNumRetries = 0 // Total number of retries attempted. If 0, retries indefinitely until maxElapsedTime is reached. // Retry Parameters for RespondToTaskV2 in the Fee Bump RespondToTaskV2MaxInterval = time.Millisecond * 500 // Maximum interval for an individual retry. RespondToTaskV2MaxElapsedTime = 0 // Maximum time all retries may take. `0` corresponds to no limit on the time of the retries. RespondToTaskV2NumRetries uint64 = 0 // Total number of retries attempted. If 0, retries indefinitely until maxElapsedTime is reached. )
Variables ¶
This section is empty.
Functions ¶
func Retry ¶
func Retry(functionToRetry func() error, config *RetryParams) 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.
func RetryWithData ¶
func RetryWithData[T any](functionToRetry func() (T, error), config *RetryParams) (T, error)
Same as Retry only that the functionToRetry can return a value upon correct execution
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
type RetryParams ¶ added in v0.12.0
type RetryParams struct { InitialInterval time.Duration // Initial delay for retry interval. MaxInterval time.Duration // Maximum interval an individual retry may have. MaxElapsedTime time.Duration // Maximum time all retries may take. `0` corresponds to no limit on the time of the retries. RandomizationFactor float64 Multiplier float64 NumRetries uint64 }
func NetworkRetryParams ¶ added in v0.12.0
func NetworkRetryParams() *RetryParams
func RespondToTaskV2 ¶ added in v0.12.0
func RespondToTaskV2() *RetryParams
func SendToChainRetryParams ¶ added in v0.12.0
func SendToChainRetryParams() *RetryParams
func WaitForTxRetryParams ¶ added in v0.12.0
func WaitForTxRetryParams(maxElapsedTime time.Duration) *RetryParams
WaitForTxRetryParams returns the retry parameters for waiting for a transaction to be included in a block. maxElapsedTime is received as parameter to allow for a custom timeout These parameters are used for the bumping fees logic.