Documentation
¶
Overview ¶
Package retry owns replay safety, attempt lifetime, and retry sequencing. Callers supply policy and observations without transferring request ownership.
Index ¶
Constants ¶
View Source
const ( // MaxRetryAfter is the fixed server-directed wait cap. MaxRetryAfter = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Policy ¶
type Policy struct {
// Attempts includes the initial attempt.
Attempts int
// Backoff runs before Retry-After selection, even when the header stops retry.
Backoff func(int) time.Duration
// AttemptTimeout remains active until the returned body is closed.
AttemptTimeout time.Duration
// RetryIf classifies outcomes only after the caller-context guard.
RetryIf func(*http.Response, error) bool
// Failed observes terminal failures without consuming their response body.
Failed func(context.Context, *http.Request, Result)
// Retry observes a selected retry before response cleanup and waiting.
Retry func(context.Context, *http.Request, Result, time.Duration)
}
Policy contains completed callbacks and attempt limits, not construction code.
type Result ¶
type Result struct {
// Number starts at one and includes rewind failures before native I/O.
Number int
// Response is returned unchanged on a terminal response; its body is owned
// by the engine until it is returned or discarded before retrying.
Response *http.Response
// Err is the native transport error or contextual request-rewind error.
Err error
}
Result retains one attempt's native outcome and identity for observations.
Click to show internal directories.
Click to hide internal directories.