Documentation
¶
Overview ¶
Package httpx provides WaxSeal's Google-facing HTTP behavior. It wraps a caller's HTTP client with bounded retries, jittered backoff, Retry-After handling, and response size limits.
No pause outlasts the caller's deadline. A backoff that would consume the remaining budget is skipped and the failure that provoked it is returned instead, so the cause reaches the caller rather than a bare context timeout that names nothing. MaxDelay is the absolute cap on a pause; this is the per-request one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBodyTooLarge = errors.New("httpx: response body exceeds cap")
ErrBodyTooLarge is returned when a response body exceeds the configured limit.
Functions ¶
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
MaxRetries int // retries AFTER the first attempt (default 2)
BaseDelay time.Duration // backoff base (default 500ms)
MaxDelay time.Duration // backoff cap (default 5s)
Logger *slog.Logger
}
Client wraps an *http.Client with bounded, jittered retries and Retry-After handling. Construct one with New.
func New ¶
New wraps hc with default retry and backoff settings. A nil hc uses http.DefaultClient. There is no client-level Timeout (it interacts poorly with multi-attempt retries); callers must drive each request with a bounded context.