timeseries

package
v0.0.0-...-31edc5d Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyTimeSeriesErr = errors.New("no records in timeseries")
)

Functions

This section is empty.

Types

type Record

type Record struct {
	Timestamp int64
	Value     float64
}

Record represents a point in the timeseries, currently holds only a float value

type TimeSeries

type TimeSeries struct {
	Name      string
	Retention int64

	Records []*Record
	// contains filtered or unexported fields
}

TimeSeries represents a time series, essentially an append-only log of point values in time

func NewTimeSeries

func NewTimeSeries(name string, retention int64) *TimeSeries

NewTestSeries create a new TimeSeries by accepting a name and a retention value

func (*TimeSeries) AddPoint

func (ts *TimeSeries) AddPoint(value float64) Record

AddPoint add a new point to an existing TimeSeries

func (*TimeSeries) AddRecord

func (ts *TimeSeries) AddRecord(record *Record)

func (*TimeSeries) Average

func (ts *TimeSeries) Average() (float64, error)

func (*TimeSeries) AverageInterval

func (ts *TimeSeries) AverageInterval(interval_ms int64) ([]Record, error)

func (*TimeSeries) Find

func (ts *TimeSeries) Find(timestamp int64) (*Record, int)

func (*TimeSeries) First

func (ts *TimeSeries) First() (*Record, error)

func (*TimeSeries) Last

func (ts *TimeSeries) Last() (*Record, error)

func (*TimeSeries) Len

func (ts *TimeSeries) Len() int

func (*TimeSeries) Max

func (ts *TimeSeries) Max() (*Record, error)

func (*TimeSeries) Min

func (ts *TimeSeries) Min() (*Record, error)

func (*TimeSeries) Range

func (ts *TimeSeries) Range(lo, hi int64) (*TimeSeries, error)

Jump to

Keyboard shortcuts

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