Documentation
¶
Overview ¶
Package retry provides retry logic with exponential backoff.
Index ¶
Constants ¶
const MaxRetryAfter = 10 * time.Minute
MaxRetryAfter is the maximum server-supplied Retry-After delay that will be honored. A hostile or broken server could otherwise park the retry loop indefinitely; above this cap the calculated backoff is used instead.
Variables ¶
This section is empty.
Functions ¶
func CalculateBackoff ¶
CalculateBackoff returns the backoff duration for the given attempt. Attempt is 0-indexed (first retry is attempt 0). Formula: initial * 2^attempt, uncapped per SDK requirements §9.3. The result is clamped to MaxInt64 nanoseconds so extreme user-configured retry counts cannot overflow time.Duration.
func ParseRetryAfter ¶
ParseRetryAfter parses the Retry-After header value. Returns the duration to wait, or 0 if not present/parseable.
func ShouldRetryError ¶
ShouldRetryError returns true if the error is transient and the request can be retried. It unwraps errors to check the underlying cause.
func ShouldRetryStatus ¶
ShouldRetryStatus returns true if the HTTP status code indicates the request can be retried. Only 501-599 are retryable. 429 (rate limit) and 500 (internal server error) are NOT retried.