data

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Truncate time.Duration

Functions

func SetTruncateValue

func SetTruncateValue(d time.Duration)

Types

type Data

type Data interface {
	Timestamp() time.Time
	Value() any
	String() string
}

func NewData

func NewData(dat any, ts time.Time) Data

type DataPoint

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

Data is an array of timestamps and values representing the same source of data over a period of time

func NewDataPoint

func NewDataPoint(dat any, ts time.Time) *DataPoint

func (DataPoint) Float

func (d DataPoint) Float() float64

Return the float64 representation of the data. If the data is not represented by a float64 value a panic will follow

func (DataPoint) Int

func (d DataPoint) Int() int

Int returns the integer value of the data. If the data is not an integer a panic will result.

func (DataPoint) String

func (d DataPoint) String() string

func (DataPoint) Timestamp

func (d DataPoint) Timestamp() time.Time

func (DataPoint) Value

func (d DataPoint) Value() any

type Timeseries

type Timeseries struct {
	ID    string `json:"id"`
	Datas []Data `json:"data"`
}

Timeseries represents a single source of data over a time period

func NewTimeseries

func NewTimeseries(ID string) *Timeseries

NewTimeseries will start a new data timeseries with the given label

func (*Timeseries) Add

func (ts *Timeseries) Add(d any) Data

Add a new Data point to the given Timeseries

func (*Timeseries) AddTimestamp

func (ts *Timeseries) AddTimestamp(d any, t time.Time) Data

Add a new Data point to the given Timeseries

func (*Timeseries) GetReadingsInRange

func (ts *Timeseries) GetReadingsInRange(start time.Time, end time.Time) []Data

func (*Timeseries) Len

func (ts *Timeseries) Len() int

Len returns the number of data points contained in this timeseries

func (*Timeseries) String

func (ts *Timeseries) String() string

String returns a human readable string describing the data contained therein.

Jump to

Keyboard shortcuts

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