Documentation
¶
Index ¶
Constants ¶
const ( DefaultMaxAttempts = 5 DefaultBaseDelay = 500 * time.Millisecond DefaultMaxDelay = 30 * time.Second )
Default parameters for the retry loop.
Variables ¶
This section is empty.
Functions ¶
func ClassifyHTTPResponse ¶
ClassifyHTTPResponse returns a RetryableError for transient HTTP failures (429, 5xx) and a plain error for permanent ones. Returns nil on success (2xx). The retryAfter duration is parsed from the Retry-After header when present.
func Do ¶
Do executes fn, retrying on RetryableError up to p.MaxAttempts times with exponential backoff and full jitter. If fn returns a non-retryable error or the context is cancelled, it returns immediately.
func IsRetryable ¶
IsRetryable returns true if the error is a RetryableError.
Types ¶
type Policy ¶
Policy controls retry behaviour.
func DefaultPolicy ¶
func DefaultPolicy() Policy
DefaultPolicy returns a sensible default retry policy.
type RetryableError ¶
RetryableError wraps an error that should be retried and optionally carries a server-suggested wait duration (e.g. from a Retry-After header).
func (*RetryableError) Error ¶
func (e *RetryableError) Error() string
func (*RetryableError) Unwrap ¶
func (e *RetryableError) Unwrap() error