Versions in this module Expand all Collapse all v1 v1.0.0 Nov 1, 2026 Changes in this version + var ErrCircuitOpen = errors.New("gotry: circuit open") + func WithPolicy(ctx context.Context, p Policy) context.Context + type Attempt struct + Err error + Number int + Request *http.Request + Response *http.Response + type Backoff interface + Delay func(retry int, prev time.Duration) time.Duration + func Constant(d time.Duration) Backoff + func DecorrelatedJitter(base, max time.Duration) Backoff + func Exponential(base, max time.Duration) Backoff + func ExponentialJitter(base, max time.Duration) Backoff + type BackoffFunc func(retry int, prev time.Duration) time.Duration + func (f BackoffFunc) Delay(retry int, prev time.Duration) time.Duration + type BreakerConfig struct + FailureThreshold int + HalfOpenProbes int + OpenDuration time.Duration + type BreakerState int + const Closed + const HalfOpen + const Open + func (s BreakerState) String() string + type Classifier func(Attempt) Decision + type Decision int + const Default + const DontRetry + const Retry + func DefaultClassifier(a Attempt) Decision + type Error struct + Attempts int + Err error + func (e *Error) Error() string + func (e *Error) Unwrap() error + type HedgeEvent struct + Attempt int + InFlight int + Request *http.Request + type Hooks struct + OnBreakerStateChange func(host string, from, to BreakerState) + OnHedge func(HedgeEvent) + OnRetry func(RetryEvent) + type Option func(*config) + func WithBackoff(b Backoff) Option + func WithBudget(ratio float64, minPerSec int) Option + func WithCircuitBreaker(cfg BreakerConfig) Option + func WithClassifier(cl Classifier) Option + func WithHedging(delay time.Duration, maxHedges int) Option + func WithHooks(h Hooks) Option + func WithIdempotencyKeyHeaders(names ...string) Option + func WithMaxAttempts(n int) Option + func WithMaxBufferedBody(n int64) Option + func WithMaxRetryAfter(d time.Duration) Option + func WithNonIdempotentRetries(allow bool) Option + func WithPerAttemptTimeout(d time.Duration) Option + func WithRetryableStatuses(codes ...int) Option + type Policy struct + AllowNonIdempotent *bool + Backoff Backoff + Classifier Classifier + HedgeDelay time.Duration + MaxAttempts int + MaxHedges int + PerAttemptTimeout time.Duration + func NoRetry() Policy + type RetryEvent struct + Attempt int + Delay time.Duration + Err error + Request *http.Request + RetryAfter bool + StatusCode int + type Transport struct + func NewTransport(base http.RoundTripper, opts ...Option) *Transport + func (t *Transport) CloseIdleConnections() + func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)