querying

package
v0.0.0-...-d2cf98a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxTime = time.Unix(1<<63-62135596801, 999999999)
	MinTime = time.Time{}
)
View Source
var (
	Window24h        = &TimeScaleDBWindow{Specifier: "24h", Interval: time.Hour * 24}
	Window6h         = &TimeScaleDBWindow{Specifier: "6h", Interval: time.Hour * 6}
	Window1h         = &TimeScaleDBWindow{Specifier: "1h", Interval: time.Hour * 1}
	Window10m        = &TimeScaleDBWindow{Specifier: "10m", Interval: time.Minute * 10}
	Window1m         = &TimeScaleDBWindow{Specifier: "1m", Interval: time.Minute * 1}
	TimeScaleWindows = []*TimeScaleDBWindow{
		Window24h,
		Window6h,
		Window1h,
		Window10m,
		Window1m,
	}
)

Functions

func Logger

func Logger(ctx context.Context) *zap.Logger

Types

type AggregateInfo

type AggregateInfo struct {
	Name     string    `json:"name"`
	Interval int32     `json:"interval"`
	Complete bool      `json:"complete"`
	Start    time.Time `json:"start"`
	End      time.Time `json:"end"`
}

type DataBackend

type DataBackend interface {
	QueryData(ctx context.Context, qp *backend.QueryParams) (*QueriedData, error)
	QueryTail(ctx context.Context, stationIDs []int32) (*SensorTailData, error)
	QueryRecentlyAggregated(ctx context.Context, stationIDs []int32, windows []time.Duration) (*RecentlyAggregated, error)
}

type DataRow

type DataRow struct {
	Time          time.Time `json:"time"`
	StationID     int32     `json:"station_id"`
	ModuleID      int64     `json:"module_id"`
	SensorID      int64     `json:"sensor_id"`
	DataStart     time.Time `json:"start"`
	DataEnd       time.Time `json:"end"`
	BucketSamples int       `json:"bucket_samples"`
	AverageValue  float64   `json:"average"`
	MinimumValue  float64   `json:"minimum"`
	MaximumValue  float64   `json:"maximum"`
	LastValue     float64   `json:"last"`
}

type LastTimeRow

type LastTimeRow struct {
	StationID int32     `json:"station_id"`
	LastTime  time.Time `json:"last_time"`
}

type QueriedData

type QueriedData struct {
	Data          []*backend.DataRow    `json:"data"`
	BucketSize    int                   `json:"bucketSize"`
	BucketSamples int                   `json:"bucketSamples"`
	DataEnd       *data.NumericWireTime `json:"dataEnd"`
}

type RecentlyAggregated

type RecentlyAggregated struct {
	Windows  map[time.Duration][]*backend.DataRow `json:"windows"`
	Stations map[int32]*StationLastTime           `json:"stations"`
}

func NewRecentlyAggregated

func NewRecentlyAggregated() *RecentlyAggregated

type SelectedAggregate

type SelectedAggregate struct {
	Specifier  string
	BucketSize int
	DataEnd    *time.Time
}

type SensorTailData

type SensorTailData struct {
	Data     []*backend.DataRow         `json:"data"`
	Stations map[int32]*StationTailInfo `json:"stations"`
}

type StationLastTime

type StationLastTime struct {
	Last *data.NumericWireTime `json:"last"`
}

type StationTailInfo

type StationTailInfo struct {
	BucketSize    int `json:"bucketSize"`
	BucketSamples int `json:"bucketSamples"`
}

type TailedStation

type TailedStation struct {
	StationID  int32
	Rows       []*backend.DataRow
	BucketSize int
}

type TimeScaleDBBackend

type TimeScaleDBBackend struct {
	// contains filtered or unexported fields
}

func NewTimeScaleDBBackend

func NewTimeScaleDBBackend(config *storage.TimeScaleDBConfig, db *sqlxcache.DB, metrics *logging.Metrics, querySpec *data.QueryingSpec) (*TimeScaleDBBackend, error)

func (*TimeScaleDBBackend) QueryData

func (tsdb *TimeScaleDBBackend) QueryData(ctx context.Context, qp *backend.QueryParams) (*QueriedData, error)

func (*TimeScaleDBBackend) QueryRecentlyAggregated

func (tsdb *TimeScaleDBBackend) QueryRecentlyAggregated(ctx context.Context, stationIDs []int32, windows []time.Duration) (*RecentlyAggregated, error)

func (*TimeScaleDBBackend) QueryTail

func (tsdb *TimeScaleDBBackend) QueryTail(ctx context.Context, stationIDs []int32) (*SensorTailData, error)

type TimeScaleDBWindow

type TimeScaleDBWindow struct {
	Specifier string
	Interval  time.Duration
}

func (*TimeScaleDBWindow) BucketSize

func (w *TimeScaleDBWindow) BucketSize() int

func (*TimeScaleDBWindow) CalculateMaximumRows

func (w *TimeScaleDBWindow) CalculateMaximumRows(start, end time.Time) int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL