Versions in this module Expand all Collapse all v1 v1.0.0 Aug 25, 2026 Changes in this version + const MaxHistoryEntries + var ErrInvalidPolicy = errors.New("invalid retry policy") + func Permanent(err error) error + func Retryable(err error) error + type Attempt struct + Attempt uint + Classification Classification + Delay time.Duration + Elapsed time.Duration + Err error + type Backoff interface + Delay func(attempt uint, previous time.Duration, random Random) time.Duration + func Constant(delay time.Duration) Backoff + func DecorrelatedJitter(base time.Duration) Backoff + func EqualJitter(backoff Backoff) Backoff + func Exponential(initial time.Duration, multiplier uint64) Backoff + func ExponentialJitter(initial time.Duration, multiplier uint64, factor float64) Backoff + func Fibonacci(unit time.Duration) Backoff + func FullJitter(backoff Backoff) Backoff + func Linear(initial, increment time.Duration) Backoff + func Polynomial(base, coefficient time.Duration, power uint) Backoff + type BudgetError struct + Kind BudgetKind + func (err *BudgetError) Error() string + func (err *BudgetError) Result() Result + func (err *BudgetError) Unwrap() error + type BudgetKind string + const BudgetAttempt + const BudgetElapsed + const BudgetSleep + const BudgetWork + type CanceledError struct + func (err *CanceledError) Error() string + func (err *CanceledError) Result() Result + func (err *CanceledError) Unwrap() error + type Classification uint8 + const ClassificationPermanent + const ClassificationRetryable + type Classifier interface + Classify func(context.Context, error) (Classification, error) + func RetryableClassifier() Classifier + type ClassifyFunc func(context.Context, error) (Classification, error) + func (function ClassifyFunc) Classify(ctx context.Context, err error) (Classification, error) + type Clock interface + Now func() time.Time + type Config struct + AttemptTimeout time.Duration + Backoff Backoff + Classifier Classifier + Clock Clock + HistoryLimit uint + MaxAttempts uint + MaxDelay time.Duration + MaxElapsed time.Duration + MaxSleep time.Duration + MinDelay time.Duration + Observer Observer + Random Random + Sleeper Sleeper + UseResilienceBudget bool + type DelayHint interface + RetryDelay func(time.Time) (time.Duration, bool) + type ExhaustedError struct + func (err *ExhaustedError) Error() string + func (err *ExhaustedError) Result() Result + func (err *ExhaustedError) Unwrap() error + type Observation struct + Attempt uint + Classification Classification + Elapsed time.Duration + NextDelay time.Duration + Reason Reason + type ObserveFunc func(Observation) + func (function ObserveFunc) Observe(observation Observation) + type Observer interface + Observe func(Observation) + type PermanentError struct + Cause error + func (err *PermanentError) Error() string + func (err *PermanentError) Unwrap() error + type Policy struct + func NewPolicy(config Config) (*Policy, error) + type Random interface + Int64n func(upper int64) int64 + type Reason string + const ReasonAttemptBudget + const ReasonAttemptsExhausted + const ReasonCanceled + const ReasonClassifierFailure + const ReasonElapsedBudget + const ReasonPermanent + const ReasonSleepBudget + const ReasonSleeperFailure + const ReasonSucceeded + const ReasonWorkBudget + type Result struct + Attempts uint + Elapsed time.Duration + FinalDelay time.Duration + History []Attempt + Reason Reason + func Do[T any](ctx context.Context, policy *Policy, ...) (T, Result, error) + type RetryableError struct + Cause error + func (err *RetryableError) Error() string + func (err *RetryableError) Unwrap() error + type SeededRandom struct + func NewRandom(seed1, seed2 uint64) *SeededRandom + func (random *SeededRandom) Int64n(upper int64) int64 + type Sleeper interface + Sleep func(context.Context, time.Duration) error + type SystemClock struct + func (SystemClock) Now() time.Time + func (SystemClock) WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) + type SystemSleeper struct + func (SystemSleeper) Sleep(ctx context.Context, delay time.Duration) error + type TimeoutClock interface + WithTimeout func(context.Context, time.Duration) (context.Context, context.CancelFunc)