Documentation
¶
Index ¶
- Variables
- type HealthStatus
- type Manager
- func (m *Manager) CheckProviderHealth(name string, llm gollm.LLM) HealthStatus
- func (m *Manager) Execute(ctx context.Context, operation func(llm gollm.LLM) error, prompt *gollm.Prompt) error
- func (m *Manager) GetHealthCheckErrors() *prometheus.CounterVec
- func (m *Manager) GetHealthStatus(name string) HealthStatus
- func (m *Manager) GetProvider() (gollm.LLM, error)
- func (m *Manager) PerformHealthCheck()
- func (m *Manager) SetProviders(providers map[string]gollm.LLM)
- func (m *Manager) UpdateHealthStatus(name string, status HealthStatus)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoHealthyProvider indicates that no healthy provider is available ErrNoHealthyProvider = errors.New("no healthy provider available") )
Functions ¶
This section is empty.
Types ¶
type HealthStatus ¶
type HealthStatus struct {
Healthy bool // Whether the provider is currently healthy
LastCheck time.Time // When the last health check was performed
ConsecutiveFails int // Number of consecutive failures
Latency time.Duration // Last observed latency
ErrorCount int64 // Total number of errors
RequestCount int64 // Total number of requests
}
HealthStatus represents the current health state of a provider
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles LLM provider management and selection
func NewManager ¶
func NewManager(cfg *config.Config, logger *zap.Logger, registry *prometheus.Registry) (*Manager, error)
NewManager creates a new provider manager
func (*Manager) CheckProviderHealth ¶ added in v0.0.11
func (m *Manager) CheckProviderHealth(name string, llm gollm.LLM) HealthStatus
CheckProviderHealth performs a health check on a provider
func (*Manager) Execute ¶ added in v0.0.11
func (m *Manager) Execute(ctx context.Context, operation func(llm gollm.LLM) error, prompt *gollm.Prompt) error
Execute coordinates provider execution with proper error handling
func (*Manager) GetHealthCheckErrors ¶ added in v0.0.11
func (m *Manager) GetHealthCheckErrors() *prometheus.CounterVec
GetHealthCheckErrors returns the health check errors counter for testing
func (*Manager) GetHealthStatus ¶ added in v0.0.12
func (m *Manager) GetHealthStatus(name string) HealthStatus
GetHealthStatus returns the health status for a provider
func (*Manager) GetProvider ¶ added in v0.0.11
GetProvider returns a healthy provider or error if none available
func (*Manager) PerformHealthCheck ¶ added in v0.0.12
func (m *Manager) PerformHealthCheck()
PerformHealthCheck performs a health check on all providers
func (*Manager) SetProviders ¶ added in v0.0.11
SetProviders replaces the current providers with new ones (for testing)
func (*Manager) UpdateHealthStatus ¶ added in v0.0.11
func (m *Manager) UpdateHealthStatus(name string, status HealthStatus)
UpdateHealthStatus updates the health status for a provider