Documentation
¶
Overview ¶
Package eyrie (internal/health) provides provider health-check tracking — the HealthState type and helpers that record and report provider liveness.
Index ¶
- type HealthCheckConfig
- type HealthChecker
- func (hc *HealthChecker) AllProviderHealth() map[string]HealthStatus
- func (hc *HealthChecker) Check(provider string) HealthStatus
- func (hc *HealthChecker) Register(provider ProviderPinger)
- func (hc *HealthChecker) Start()
- func (hc *HealthChecker) Stop()
- func (hc *HealthChecker) Unregister(name string)
- type HealthState
- type HealthStatus
- type ProviderPinger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthCheckConfig ¶
type HealthCheckConfig struct {
// Interval between periodic health checks. Default: 30s.
Interval time.Duration
// Timeout for each individual ping. Default: 5s.
Timeout time.Duration
// DegradedThreshold: latency above this marks provider as Degraded. Default: 2s.
DegradedThreshold time.Duration
// UnhealthyAfter: number of consecutive failures before marking Unhealthy. Default: 3.
UnhealthyAfter int
// DegradedAfter: number of consecutive failures before marking Degraded. Default: 1.
DegradedAfter int
}
HealthCheckConfig configures the HealthChecker behavior.
func DefaultHealthCheckConfig ¶
func DefaultHealthCheckConfig() HealthCheckConfig
DefaultHealthCheckConfig returns sensible default configuration.
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker periodically pings LLM providers to determine their health. It is safe for concurrent use. A nil *HealthChecker is safe (all methods are no-ops).
func NewHealthChecker ¶
func NewHealthChecker(cfg HealthCheckConfig) *HealthChecker
NewHealthChecker creates a new HealthChecker with the given configuration. Pass a zero-value config to use defaults.
func (*HealthChecker) AllProviderHealth ¶
func (hc *HealthChecker) AllProviderHealth() map[string]HealthStatus
AllProviderHealth returns the current health status of all registered providers.
func (*HealthChecker) Check ¶
func (hc *HealthChecker) Check(provider string) HealthStatus
Check performs an immediate health check on a single provider and returns the resulting HealthStatus. Returns an Unhealthy status if the provider is not registered.
func (*HealthChecker) Register ¶
func (hc *HealthChecker) Register(provider ProviderPinger)
Register adds a provider to be health-checked. Can be called at any time.
func (*HealthChecker) Start ¶
func (hc *HealthChecker) Start()
Start begins periodic background health checks. Call Stop() to halt. No-op if already started or if hc is nil.
func (*HealthChecker) Stop ¶
func (hc *HealthChecker) Stop()
Stop halts periodic health checking. Blocks until the background loop exits. No-op if not started or if hc is nil.
func (*HealthChecker) Unregister ¶
func (hc *HealthChecker) Unregister(name string)
Unregister removes a provider from health checking.
type HealthState ¶
type HealthState int
HealthState represents the health condition of a provider.
const ( // Healthy indicates the provider is responding normally. Healthy HealthState = iota // Degraded indicates the provider is responding but with elevated latency or intermittent errors. Degraded // Unhealthy indicates the provider is not responding or consistently failing. Unhealthy )
func (HealthState) String ¶
func (h HealthState) String() string
String returns a human-readable representation of HealthState.
type HealthStatus ¶
type HealthStatus struct {
State HealthState `json:"state"`
Latency time.Duration `json:"latency"`
LastChecked time.Time `json:"last_checked"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
HealthStatus holds the current health status for a provider, including measured latency and the time of the last health check.
func (HealthStatus) IsHealthy ¶
func (hs HealthStatus) IsHealthy() bool
IsHealthy returns true if the provider state is Healthy.