Documentation
¶
Index ¶
- type Measurement
- type Measurements
- type PostgresDB
- func (db *PostgresDB) Get(from, to time.Time) (Measurements, error)
- func (db *PostgresDB) GetDataRange() (time.Time, time.Time, error)
- func (db *PostgresDB) GetWeather(id int) (string, error)
- func (db *PostgresDB) GetWeatherID(weather string) (int, error)
- func (db *PostgresDB) IsHealthy(ctx context.Context) error
- func (db *PostgresDB) Store(measurement Measurement) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Measurement ¶
type Measurement struct {
Timestamp time.Time `db:"timestamp"`
Weather string `db:"weather"`
Power float64 `db:"power"`
Intensity float64 `db:"intensity"`
}
func (Measurement) LogValue ¶
func (m Measurement) LogValue() slog.Value
type Measurements ¶
type Measurements []Measurement
func (Measurements) Fold ¶
func (m Measurements) Fold() Measurements
func (Measurements) Len ¶
func (m Measurements) Len() int
type PostgresDB ¶
type PostgresDB struct {
prometheus.Collector
DBX *sqlx.DB
// contains filtered or unexported fields
}
func NewPostgresDB ¶
func NewPostgresDB(connectionString string) (*PostgresDB, error)
func (*PostgresDB) Get ¶
func (db *PostgresDB) Get(from, to time.Time) (Measurements, error)
func (*PostgresDB) GetDataRange ¶
func (*PostgresDB) GetWeather ¶
func (db *PostgresDB) GetWeather(id int) (string, error)
func (*PostgresDB) GetWeatherID ¶
func (db *PostgresDB) GetWeatherID(weather string) (int, error)
func (*PostgresDB) IsHealthy ¶ added in v0.16.2
func (db *PostgresDB) IsHealthy(ctx context.Context) error
func (*PostgresDB) Store ¶
func (db *PostgresDB) Store(measurement Measurement) error
Click to show internal directories.
Click to hide internal directories.