Documentation
¶
Overview ¶
Package backoff computes retry delays for failed task executions. The delay grows with the retry count according to the chosen Kind: exponential (base*2^retried) and linear (base*(retried+1)) grow a ceiling and draw the delay uniformly from [0, ceiling) (full jitter, which spreads retry storms), while fixed returns base exactly, for predictable spacing such as a rate-limited downstream. Every delay is bounded by the configured maximum.
Index ¶
Constants ¶
const ( // DefaultBase is the backoff ceiling of the first retry. DefaultBase = 2 * time.Second // DefaultCap bounds the backoff ceiling regardless of retry count. DefaultCap = 15 * time.Minute )
Server-side retry backoff defaults.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶ added in v0.3.0
type Kind uint8
Kind selects how a Strategy's delay ceiling grows with the retry count.
const ( // Exponential doubles the ceiling each retry: base*2^retried. Exponential Kind = iota // Linear grows the ceiling linearly: base*(retried+1). Linear // Fixed returns base exactly on every retry (no jitter), for predictable // spacing such as a steady interval against a rate-limited downstream. Fixed )
type Strategy ¶
type Strategy struct {
// contains filtered or unexported fields
}
Strategy computes full-jitter retry delays. The zero value is unusable; build one with New or NewWithKind.
func New ¶
New builds a full-jitter exponential Strategy with the given first-retry ceiling and overall maximum delay.
func NewWithKind ¶ added in v0.3.0
NewWithKind builds a Strategy with an explicit growth kind.