Versions in this module Expand all Collapse all v0 v0.1.0 Aug 2, 2026 Changes in this version + var ErrAttemptsExhausted = errors.New("stormbreak: retry attempts exhausted") + var ErrBudgetExhausted = errors.New("stormbreak: retry budget exhausted") + var ErrInvalidBudget = errors.New("stormbreak: invalid retry budget configuration") + var ErrInvalidPolicy = errors.New("stormbreak: invalid retry policy") + func AlwaysRetry(err error) bool + func Backoff(policy Policy, attempt int) time.Duration + func DoVoid(ctx context.Context, budget Budget, policy Policy, ...) error + func Do[T any](ctx context.Context, budget Budget, policy Policy, ...) (T, error) + func IsPermanent(err error) bool + func NeverRetry(error) bool + func Permanent(err error) error + type AttemptEvent struct + Attempt int + type Budget interface + Allow func() bool + Capacity func() int64 + Remaining func() int64 + Reset func() + type BudgetEvent struct + Attempts int + LastError error + Remaining int64 + type BudgetSnapshot struct + Capacity int64 + Exhausted bool + RefillInterval time.Duration + RefillRate int64 + Remaining int64 + type Classifier func(error) bool + type Config struct + Capacity int64 + RefillInterval time.Duration + RefillRate int64 + type FailureEvent struct + Attempt int + Error error + type Hooks struct + OnAttempt func(AttemptEvent) + OnBudgetExhausted func(BudgetEvent) + OnFailure func(FailureEvent) + OnRetry func(RetryEvent) + OnSuccess func(SuccessEvent) + type Option func(*options) + func WithClassifier(classifier Classifier) Option + func WithHooks(hooks Hooks) Option + func WithRandomSource(source func() float64) Option + type Policy struct + BaseDelay time.Duration + Jitter bool + MaxAttempts int + MaxDelay time.Duration + Multiplier float64 + func DefaultPolicy() Policy + func (p Policy) Validate() error + type Registry struct + func NewRegistry() *Registry + func (r *Registry) Create(name string, config Config) (*TokenBudget, error) + func (r *Registry) Delete(name string) bool + func (r *Registry) Get(name string) (*TokenBudget, bool) + func (r *Registry) Names() []string + func (r *Registry) Snapshot() map[string]BudgetSnapshot + type RetryError struct + Attempts int + Cause error + LastError error + func (e *RetryError) Error() string + func (e *RetryError) Unwrap() error + type RetryEvent struct + Attempt int + BudgetRemaining int64 + Delay time.Duration + Error error + type SuccessEvent struct + Attempts int + Elapsed time.Duration + type TokenBudget struct + func NewBudget(config Config) (*TokenBudget, error) + func (b *TokenBudget) Allow() bool + func (b *TokenBudget) Capacity() int64 + func (b *TokenBudget) Remaining() int64 + func (b *TokenBudget) Reset() + func (b *TokenBudget) Snapshot() BudgetSnapshot