Documentation ¶
Overview ¶
Package reading provides persistence logic for sensor readings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ForEachFunc ¶
The ForEachFunc type is a function invoked when calling PostgresRepository.ForEachOnDate.
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
The PostgresRepository type is used to persist Reading data into a PostgreSQL instance.
func NewPostgresRepository ¶
func NewPostgresRepository(db *sql.DB) *PostgresRepository
NewPostgresRepository returns a new instance of the PostgresRepository type that will perform queries against the provided sql.DB instance.
func (*PostgresRepository) ForEachOnDate ¶
func (pr *PostgresRepository) ForEachOnDate(ctx context.Context, date time.Time, fn ForEachFunc) error
ForEachOnDate iterates through all readings stored in the database on the date component of the given time. For each record, the ForEachFunc is invoked. Iteration will stop when there are no more records, the context is cancelled or the ForEachFunc returns an error. Readings are processed in batches of 100 at the time.