Documentation
¶
Index ¶
- type CheckResult
- type HealthChecker
- type HealthStatus
- type MemoryOffsetStore
- func (s *MemoryOffsetStore) GetLastRuntimeTime(ctx context.Context, thermostatID string) (time.Time, error)
- func (s *MemoryOffsetStore) GetLastSnapshotTime(ctx context.Context, thermostatID string) (time.Time, error)
- func (s *MemoryOffsetStore) SetLastRuntimeTime(ctx context.Context, thermostatID string, timestamp time.Time) error
- func (s *MemoryOffsetStore) SetLastSnapshotTime(ctx context.Context, thermostatID string, timestamp time.Time) error
- type Metrics
- type MetricsCollector
- func (m *MetricsCollector) GetMetrics() Metrics
- func (m *MetricsCollector) RecordProviderError(providerName string)
- func (m *MetricsCollector) RecordProviderRequest(providerName string)
- func (m *MetricsCollector) RecordSinkError(sinkName string)
- func (m *MetricsCollector) RecordSinkWrite(sinkName string, documentCount int64)
- func (m *MetricsCollector) ServeMetrics() http.Handler
- type Normalizer
- func (n *Normalizer) NormalizeDeviceSnapshot(providerData model.Snapshot, provider string) *model.DeviceSnapshot
- func (n *Normalizer) NormalizeRuntime5m(providerData model.RuntimeRow, provider string) (*model.Runtime5m, error)
- func (n *Normalizer) NormalizeTransition(thermostatRef model.ThermostatRef, eventTime time.Time, ...) *model.Transition
- type OffsetStore
- type ProviderMetrics
- type SQLiteOffsetStore
- func (s *SQLiteOffsetStore) Close() error
- func (s *SQLiteOffsetStore) GetLastRuntimeTime(ctx context.Context, thermostatID string) (time.Time, error)
- func (s *SQLiteOffsetStore) GetLastSnapshotTime(ctx context.Context, thermostatID string) (time.Time, error)
- func (s *SQLiteOffsetStore) SetLastRuntimeTime(ctx context.Context, thermostatID string, timestamp time.Time) error
- func (s *SQLiteOffsetStore) SetLastSnapshotTime(ctx context.Context, thermostatID string, timestamp time.Time) error
- type Scheduler
- type SinkMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct {
Status string `json:"status"` // "pass", "fail", "warn"
Message string `json:"message,omitempty"`
DurationMS int64 `json:"duration_ms"`
LastChecked string `json:"last_checked"`
}
CheckResult represents the result of a health check
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker provides health check functionality
func NewHealthChecker ¶
func NewHealthChecker(providers []model.Provider, sinks []model.Sink) *HealthChecker
NewHealthChecker creates a new health checker
func (*HealthChecker) CheckHealth ¶
func (h *HealthChecker) CheckHealth(ctx context.Context) HealthStatus
CheckHealth performs all health checks
func (*HealthChecker) GetStatus ¶
func (h *HealthChecker) GetStatus() HealthStatus
GetStatus returns the current health status
func (*HealthChecker) ServeHealth ¶
func (h *HealthChecker) ServeHealth() http.Handler
ServeHealth provides an HTTP handler for health checks
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"` // "healthy", "degraded", "unhealthy"
Timestamp time.Time `json:"timestamp"`
Checks map[string]CheckResult `json:"checks"`
}
HealthStatus represents the overall health status
type MemoryOffsetStore ¶
type MemoryOffsetStore struct {
// contains filtered or unexported fields
}
MemoryOffsetStore is an in-memory implementation of OffsetStore for testing
func NewMemoryOffsetStore ¶
func NewMemoryOffsetStore() *MemoryOffsetStore
NewMemoryOffsetStore creates a new in-memory offset store
func (*MemoryOffsetStore) GetLastRuntimeTime ¶
func (s *MemoryOffsetStore) GetLastRuntimeTime(ctx context.Context, thermostatID string) (time.Time, error)
GetLastRuntimeTime returns the last runtime timestamp for a thermostat
func (*MemoryOffsetStore) GetLastSnapshotTime ¶
func (s *MemoryOffsetStore) GetLastSnapshotTime(ctx context.Context, thermostatID string) (time.Time, error)
GetLastSnapshotTime returns the last snapshot timestamp for a thermostat
func (*MemoryOffsetStore) SetLastRuntimeTime ¶
func (s *MemoryOffsetStore) SetLastRuntimeTime(ctx context.Context, thermostatID string, timestamp time.Time) error
SetLastRuntimeTime sets the last runtime timestamp for a thermostat
func (*MemoryOffsetStore) SetLastSnapshotTime ¶
func (s *MemoryOffsetStore) SetLastSnapshotTime(ctx context.Context, thermostatID string, timestamp time.Time) error
SetLastSnapshotTime sets the last snapshot timestamp for a thermostat
type Metrics ¶
type Metrics struct {
UptimeSeconds float64 `json:"uptime_seconds"`
Providers map[string]ProviderMetrics `json:"providers"`
Sinks map[string]SinkMetrics `json:"sinks"`
}
Metrics represents the overall metrics structure
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector provides basic metrics collection
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a new metrics collector
func (*MetricsCollector) GetMetrics ¶
func (m *MetricsCollector) GetMetrics() Metrics
GetMetrics returns current metrics
func (*MetricsCollector) RecordProviderError ¶
func (m *MetricsCollector) RecordProviderError(providerName string)
RecordProviderError records a provider error
func (*MetricsCollector) RecordProviderRequest ¶
func (m *MetricsCollector) RecordProviderRequest(providerName string)
RecordProviderRequest records a provider request
func (*MetricsCollector) RecordSinkError ¶
func (m *MetricsCollector) RecordSinkError(sinkName string)
RecordSinkError records a sink error
func (*MetricsCollector) RecordSinkWrite ¶
func (m *MetricsCollector) RecordSinkWrite(sinkName string, documentCount int64)
RecordSinkWrite records a sink write operation
func (*MetricsCollector) ServeMetrics ¶
func (m *MetricsCollector) ServeMetrics() http.Handler
ServeMetrics provides an HTTP handler for metrics
type Normalizer ¶
type Normalizer struct {
// contains filtered or unexported fields
}
Normalizer converts provider-specific data to canonical format
func NewNormalizer ¶
func NewNormalizer(timezone string) (*Normalizer, error)
NewNormalizer creates a new normalizer
func (*Normalizer) NormalizeDeviceSnapshot ¶
func (n *Normalizer) NormalizeDeviceSnapshot( providerData model.Snapshot, provider string, ) *model.DeviceSnapshot
NormalizeDeviceSnapshot converts provider snapshot data to canonical format
func (*Normalizer) NormalizeRuntime5m ¶
func (n *Normalizer) NormalizeRuntime5m(providerData model.RuntimeRow, provider string) (*model.Runtime5m, error)
NormalizeRuntime5m converts provider runtime data to canonical format
func (*Normalizer) NormalizeTransition ¶
func (n *Normalizer) NormalizeTransition( thermostatRef model.ThermostatRef, eventTime time.Time, prevState, nextState model.State, eventInfo model.EventInfo, provider string, providerData any, ) *model.Transition
NormalizeTransition creates a transition document from state changes
type OffsetStore ¶
type OffsetStore interface {
// GetLastRuntimeTime returns the last runtime timestamp for a thermostat
GetLastRuntimeTime(ctx context.Context, thermostatID string) (time.Time, error)
// SetLastRuntimeTime sets the last runtime timestamp for a thermostat
SetLastRuntimeTime(ctx context.Context, thermostatID string, timestamp time.Time) error
// GetLastSnapshotTime returns the last snapshot timestamp for a thermostat
GetLastSnapshotTime(ctx context.Context, thermostatID string) (time.Time, error)
// SetLastSnapshotTime sets the last snapshot timestamp for a thermostat
SetLastSnapshotTime(ctx context.Context, thermostatID string, timestamp time.Time) error
}
OffsetStore manages persistence of polling offsets
type ProviderMetrics ¶
type ProviderMetrics struct {
RequestsTotal int64 `json:"requests_total"`
ErrorsTotal int64 `json:"errors_total"`
LastRequestTime string `json:"last_request_time"`
}
ProviderMetrics represents metrics for a provider
type SQLiteOffsetStore ¶
type SQLiteOffsetStore struct {
// contains filtered or unexported fields
}
SQLiteOffsetStore implements OffsetStore using SQLite This provides persistent storage of polling offsets across restarts
func NewSQLiteOffsetStore ¶
func NewSQLiteOffsetStore(dbPath string) (*SQLiteOffsetStore, error)
NewSQLiteOffsetStore creates a new SQLite-based offset store The dbPath parameter specifies the path to the SQLite database file
func (*SQLiteOffsetStore) Close ¶
func (s *SQLiteOffsetStore) Close() error
Close closes the database connection
func (*SQLiteOffsetStore) GetLastRuntimeTime ¶
func (s *SQLiteOffsetStore) GetLastRuntimeTime(ctx context.Context, thermostatID string) (time.Time, error)
GetLastRuntimeTime returns the last runtime timestamp for a thermostat
func (*SQLiteOffsetStore) GetLastSnapshotTime ¶
func (s *SQLiteOffsetStore) GetLastSnapshotTime(ctx context.Context, thermostatID string) (time.Time, error)
GetLastSnapshotTime returns the last snapshot timestamp for a thermostat
func (*SQLiteOffsetStore) SetLastRuntimeTime ¶
func (s *SQLiteOffsetStore) SetLastRuntimeTime(ctx context.Context, thermostatID string, timestamp time.Time) error
SetLastRuntimeTime sets the last runtime timestamp for a thermostat
func (*SQLiteOffsetStore) SetLastSnapshotTime ¶
func (s *SQLiteOffsetStore) SetLastSnapshotTime(ctx context.Context, thermostatID string, timestamp time.Time) error
SetLastSnapshotTime sets the last snapshot timestamp for a thermostat
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages the polling of thermostats and data collection
func NewScheduler ¶
func NewScheduler( providers []model.Provider, sinks []model.Sink, normalizer *Normalizer, offsetStore OffsetStore, pollInterval, backfillWindow time.Duration, metrics *MetricsCollector, logger *slog.Logger, ) *Scheduler
NewScheduler creates a new scheduler