Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRetryable ¶
func IsRetryable(class ErrorClass) bool
IsRetryable returns true if the error class warrants a retry.
Types ¶
type ErrorClass ¶
type ErrorClass int
ErrorClass categorizes an error for retry decisions.
const ( ErrorClassUnknown ErrorClass = iota ErrorClassContextOverflow ErrorClassRateLimit ErrorClassOverloaded ErrorClassServerError ErrorClassNetwork )
func ClassifyError ¶
func ClassifyError(err error) (ErrorClass, string)
ClassifyError examines an error and returns its class and a human-readable reason.
type Policy ¶
type Policy struct {
MaxAttempts int
InitialDelay time.Duration
MaxDelay time.Duration
BackoffFactor float64
}
Policy configures retry behavior with exponential backoff and retry-after header support.
func DefaultPolicy ¶
func DefaultPolicy() *Policy
DefaultPolicy returns a retry policy with sensible defaults for LLM APIs: 3 attempts, 1s initial delay, 30s max delay, 2x backoff factor.
func (*Policy) Delay ¶
Delay computes the wait duration for the given attempt number (1-based). If headers contain retry-after or retry-after-ms, those take precedence.
Click to show internal directories.
Click to hide internal directories.