Documentation
¶
Overview ¶
Package retry provides exponential backoff retry logic for transient failures in RPC calls, HTTP requests, and transaction submissions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMaxRetries = errors.New("max retries exceeded")
ErrMaxRetries is returned when all retry attempts are exhausted. The underlying cause is wrapped: errors.Is(err, ErrMaxRetries) == true.
Functions ¶
Types ¶
type Config ¶
type Config struct {
MaxRetries int
InitialDelay time.Duration
MaxDelay time.Duration
Multiplier float64
RetryIf func(error) bool // nil = retry all non-context errors
}
Config holds retry parameters.
type Option ¶
type Option func(*Config)
Option configures retry behavior.
func WithInitialDelay ¶
WithInitialDelay sets the base delay before the first retry.
func WithMaxDelay ¶
WithMaxDelay sets the upper bound on backoff delay.
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retries (not counting the initial attempt).
func WithMultiplier ¶
WithMultiplier sets the exponential backoff multiplier.
func WithRetryIf ¶
WithRetryIf sets a predicate that determines whether an error is retryable. If the predicate returns false, the error is returned immediately without wrapping.