Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mode ¶
type Mode string
Mode represents an operating mode that controls cost/quality trade-offs.
type ProviderStats ¶
type ProviderStats struct {
ProviderID string
AvgLatencyMS float64
ErrorRate float64
TotalSuccessful int
}
ProviderStats holds aggregated telemetry statistics for a single provider.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router selects providers based on telemetry-derived heuristic scores.
func (*Router) LoadTelemetryStats ¶
LoadTelemetryStats reads the telemetry JSONL file and aggregates per-provider statistics (average latency, error rate, total successful queries).
func (*Router) ScoreProvider ¶
func (r *Router) ScoreProvider(stats ProviderStats) float64
ScoreProvider computes a heuristic score for a provider based on its stats. Higher scores indicate better providers. Providers with zero history receive a neutral score of 1.0.
func (*Router) SelectProviders ¶
func (r *Router) SelectProviders(mode Mode, allHealthy []provider.Provider, primaryID string) []provider.Provider
SelectProviders returns a subset of allHealthy providers based on the given mode and heuristic scores.
- quick: returns only the primary provider
- balanced: returns the primary plus the best-scoring non-primary
- thorough: returns all healthy providers