Documentation
¶
Overview ¶
Package timeout provides provider health tracking with sliding-window failure detection and cooldown-based timeout.
Index ¶
Constants ¶
View Source
const DefaultThreshold = 5
DefaultThreshold is the number of failures within the window that triggers a provider timeout. Exported so callers can rely on the package default without repeating the magic number.
View Source
const DefaultWindow = 10 * time.Minute
DefaultWindow is the sliding window duration for failure counting. Exported so callers can rely on the package default without repeating the magic number.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Now func() time.Time // Clock function; nil defaults to time.Now.
Threshold int // failures within window to trigger (default: DefaultThreshold)
Window time.Duration // sliding window (default: DefaultWindow)
Cooldown time.Duration // cooldown after triggering
}
Config holds provider timeout settings.
type ProviderHealth ¶
type ProviderHealth interface {
IsTimedOut(provider api.ProviderID) bool
RecordSuccess(provider api.ProviderID)
RecordFailure(provider api.ProviderID, err error)
Status() map[api.ProviderID]api.ProviderStatus
Reset()
}
ProviderHealth abstracts provider timeout tracking.
func New ¶
func New(cfg Config) ProviderHealth
New creates a provider timeout tracker with the given config.
Click to show internal directories.
Click to hide internal directories.