Documentation ¶
Index ¶
- Constants
- func GetCreateTablesSQL() string
- func GetInsertMetricSQL() string
- func GetSchemaVersion(db *sql.DB) (int, error)
- func InitSchema(db *sql.DB) error
- func TableExists(db *sql.DB, tableName string) (bool, error)
- func ValidateAndUpdateSchema(db *sql.DB) error
- type Config
- type FanMetrics
- type MetricsCollector
- type MetricsRepository
- type MetricsSnapshot
- type PowerMetrics
- type StateMetrics
- type TempMetrics
Constants ¶
View Source
const ( // Configuration Errors ErrInvalidConfig = errors.ErrInvalidConfig ErrInvalidDBPath = errors.ErrorCode("metrics_invalid_db_path") // Schema Errors ErrSchemaInitFailed = errors.ErrorCode("metrics_schema_init_failed") ErrSchemaValidationFailed = errors.ErrorCode("metrics_schema_validation_failed") ErrSchemaMigrationFailed = errors.ErrorCode("metrics_schema_migration_failed") ErrTransactionFailed = errors.ErrorCode("metrics_transaction_failed") // Storage Errors ErrStorageAccess = errors.ErrorCode("metrics_storage_access_failed") ErrStorageInit = errors.ErrInitFailed ErrStorageClose = errors.ErrShutdownFailed // Service Errors ErrServiceShutdown = errors.ErrShutdownFailed // Collection Errors ErrMetricsCollection = errors.ErrorCode("metrics_metrics_collection_failed") ErrInvalidMetrics = errors.ErrorCode("metrics_invalid_metrics") // Operation Errors ErrOperationTimeout = errors.ErrTimeout )
View Source
const (
SchemaVersion = 1 // Increment version for breaking change
)
Variables ¶
This section is empty.
Functions ¶
func GetInsertMetricSQL ¶
func GetInsertMetricSQL() string
GetInsertMetricSQL returns the SQL to insert a metric
func GetSchemaVersion ¶
GetSchemaVersion returns the current schema version
func InitSchema ¶
InitSchema creates a new database schema with the current version
func TableExists ¶
TableExists checks if a table exists
func ValidateAndUpdateSchema ¶
ValidateAndUpdateSchema checks the schema version and recreates it if needed. If a schema exists but the version doesn't match, it creates a backup before recreating the schema.
Types ¶
type Config ¶
func DefaultConfig ¶
func DefaultConfig() Config
type MetricsCollector ¶
type MetricsCollector interface { Record(ctx context.Context, snapshot *MetricsSnapshot) error Close() error }
MetricsCollector defines the core domain interface
func NewService ¶
func NewService(cfg Config) (MetricsCollector, error)
type MetricsRepository ¶
type MetricsRepository interface { Record(snapshot *MetricsSnapshot) error Close() error }
Repository defines the interface for metrics data storage
func NewRepository ¶
func NewRepository(cfg Config) (MetricsRepository, error)
type MetricsSnapshot ¶
type MetricsSnapshot struct { Timestamp time.Time FanSpeed FanMetrics Temperature TempMetrics PowerLimit PowerMetrics SystemState StateMetrics }
MetricsSnapshot represents domain entities
type PowerMetrics ¶
type StateMetrics ¶
type TempMetrics ¶
Click to show internal directories.
Click to hide internal directories.