Documentation
¶
Overview ¶
db.go
Index ¶
- type DBMetric
- type Database
- func (db *Database) AddMetric(metric DBMetric) error
- func (db *Database) DecrementMetric(metricName string, decrement float64) error
- func (db *Database) DeleteMetric(metricName string) error
- func (db *Database) GetMetric(metricName string) (*DBMetric, error)
- func (db *Database) GetMetrics() ([]DBMetric, error)
- func (db *Database) IncrementMetric(metricName string, increment float64) error
- func (db *Database) ResetDailyMetrics() error
- func (db *Database) StartDailyResetScheduler(stopChan chan bool)
- func (db *Database) UpdateMetric(metricName string, newValue float64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBMetric ¶
type DBMetric struct { MetricName string Type string Unit string Value float64 ResetDaily bool LastReset time.Time }
DBMetric represents a metric stored in the database
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database encapsulates the SQLite connection and a mutex for thread safety
func NewDatabase ¶
NewDatabase initializes a new Database instance
func (*Database) DecrementMetric ¶
DecrementMetric decreases the value of a metric by a specified amount
func (*Database) DeleteMetric ¶
DeleteMetric removes a metric from the database by its name.
func (*Database) GetMetrics ¶
GetMetrics retrieves all metrics from the database
func (*Database) IncrementMetric ¶
IncrementMetric increases the value of a metric by a specified amount
func (*Database) ResetDailyMetrics ¶
ResetDailyMetrics resets all metrics that are marked to reset daily and haven't been reset today
func (*Database) StartDailyResetScheduler ¶
StartDailyResetScheduler starts a scheduler that resets daily metrics at midnight using Go channels.