Documentation
¶
Overview ¶
Package retry provides a per-instance decorator over model.Model that owns the per-attempt deadline for every dispatch shape and retries ONLY genuinely transient post-load errors (ADR-0031 Decisions 4 and 5). It is built so it never fires for the cold-load case (F6): a per-attempt deadline expiry is non-retryable. The decorator mirrors the brain.WithModelID pattern (wrap, delegate, delegate Name()).
Index ¶
Constants ¶
const ( // BackoffBase is the first backoff step; each retry doubles it. BackoffBase = 200 * time.Millisecond // MaxBackoffPerWait caps a single backoff wait (the exponential is clamped // here). Full jitter draws uniformly in [0, min(cap, base·2ⁿ)). MaxBackoffPerWait = 2 * time.Second // RetryAfterCap caps how long a 429's Retry-After hint may push a wait, so a // hostile or erroneous Retry-After cannot blow the derived ceiling. The wait // is further bounded at runtime by the remaining parent budget (FR-A2). RetryAfterCap = 30 * time.Second )
Backoff schedule constants (ADR-0031 Decision 4, FR-B1/FR-A1). Exported so the app's ceiling derivation can budget the worst-case backoff (backoffBudget_i = MaxRetries_i × MaxBackoffPerWait, FR-A3).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Clock ¶
Clock abstracts the backoff sleep so tests never wait in wall-clock time. Sleep must honor ctx: a cancel during the wait returns promptly with a non-nil error.
type Config ¶
Config holds the per-instance retry parameters resolved from config. PerAttempt is the per-attempt deadline (Config.EffectiveRequestTimeout); MaxRetries is the extra-attempt budget (0 disables retry — the decorator then still applies the per-attempt deadline, SV3).
type Option ¶
type Option func(*decorator)
Option configures the decorator's test seams.
func WithMetrics ¶
WithMetrics injects the observability backend the decorator emits retry counters through (ADR-0031 sub-phase 7). Default: metrics.Nop{} (no emission). A nil argument is ignored, keeping the Nop default.