Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackoffRegistry ¶
type BackoffRegistry struct {
// contains filtered or unexported fields
}
BackoffRegistry tracks backoff state per domain using decorrelated jitter.
func NewBackoffRegistry ¶
func NewBackoffRegistry(initialMs, maxMs int, multiplier float64, maxAttempts int) *BackoffRegistry
NewBackoffRegistry creates a BackoffRegistry from config values.
func (*BackoffRegistry) Attempts ¶
func (r *BackoffRegistry) Attempts(domain string) int
Attempts returns the current backoff attempt count for a domain.
func (*BackoffRegistry) MaxAttempts ¶
func (r *BackoffRegistry) MaxAttempts() int
MaxAttempts returns the configured maximum retry attempts.
func (*BackoffRegistry) RecordError ¶
func (r *BackoffRegistry) RecordError(domain string) time.Duration
RecordError notes a transient error for the given domain and updates backoff. Returns the delay that will be applied before the next attempt.
func (*BackoffRegistry) RecordSuccess ¶
func (r *BackoffRegistry) RecordSuccess(domain string)
RecordSuccess resets the backoff state for the domain.
func (*BackoffRegistry) Wait ¶
func (r *BackoffRegistry) Wait(ctx context.Context, domain string) error
Wait blocks until the backoff delay for the domain has elapsed, or ctx is done. If the domain has reached max_attempts and its delay has expired, the entry is evicted so the map does not grow without bound.
type ErrorClass ¶
type ErrorClass int
ErrorClass categorises an HTTP error for backoff decisions.
const ( ErrorClassNone ErrorClass = iota // success ErrorClassTransient // 429, 502, 503, 504 — back off and retry ErrorClassPermanent // 400, 403, 404 — log and skip ErrorClassFatal // context cancelled — drop silently )
func ClassifyError ¶
func ClassifyError(err error) ErrorClass
ClassifyError checks a Go error for context cancellation.
func ClassifyStatusCode ¶
func ClassifyStatusCode(code int) ErrorClass
ClassifyStatusCode returns the ErrorClass for the given status code. It is used for both HTTP status codes and DNS RCODEs (mapped to HTTP-like codes by the DNS driver before being passed here).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maintains per-domain token bucket rate limiters.
func NewRegistry ¶
NewRegistry creates a Registry with the given defaults and per-domain overrides.