Documentation
¶
Overview ¶
Package retry provides utilities for retrying operations with exponential backoff and classification of transient vs permanent errors.
Index ¶
Constants ¶
View Source
const ( // DefaultMaxRetries is the default maximum number of retry attempts DefaultMaxRetries = 3 // DefaultInitialDelay is the default initial delay between retries DefaultInitialDelay = 100 * time.Millisecond // DefaultMaxDelay is the default maximum delay between retries DefaultMaxDelay = 10 * time.Second // DefaultBackoffFactor is the default exponential backoff factor DefaultBackoffFactor = 2.0 // DefaultJitter is the default jitter factor to add randomness DefaultJitter = 0.1 )
Constants for retry configuration
Variables ¶
This section is empty.
Functions ¶
func IsTransientError ¶
IsTransientError determines if an error is transient and should be retried
Types ¶
type Config ¶
type Config struct {
// MaxRetries is the maximum number of retry attempts (excluding the initial attempt)
MaxRetries int
// InitialDelay is the initial delay between retries
InitialDelay time.Duration
// MaxDelay is the maximum delay between retries
MaxDelay time.Duration
// BackoffFactor is the exponential backoff factor
BackoffFactor float64
// Jitter adds randomness to delays to avoid thundering herd
Jitter float64
// Logger for logging retry attempts
Logger logr.Logger
// TestDelay is the delay to add to the retry loop to simulate a test environment
TestDelay time.Duration
}
Config holds the configuration for retry operations
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a default retry configuration
type RetryableError ¶
RetryableError represents an error that can be retried
func NewRetryableError ¶
func NewRetryableError(err error, retryable bool, operation string) *RetryableError
NewRetryableError creates a new retryable error
func (*RetryableError) Error ¶
func (e *RetryableError) Error() string
func (*RetryableError) Unwrap ¶
func (e *RetryableError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.