Documentation ¶
Index ¶
- Variables
- type Clock
- type Granularity
- type Option
- type PointValue
- type TSType
- type TimeSeries
- func (t *TimeSeries) Increase(amount float64)
- func (t *TimeSeries) IncreaseAtTime(amount float64, time time.Time)
- func (t *TimeSeries) Range(start, end time.Time) (float64, error)
- func (t *TimeSeries) RangeValues(start, end time.Time) ([]PointValue, error)
- func (t *TimeSeries) Recent(duration time.Duration) (float64, error)
- func (t *TimeSeries) RecentValues(duration time.Duration) ([]PointValue, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadRange indicates that the given range is invalid. Start should always be <= End ErrBadRange = errors.New("timeseries: range is invalid") // ErrBadGranularities indicates that the provided granularities are not strictly increasing ErrBadGranularities = errors.New("timeseries: granularities must be strictly increasing and non empty") // ErrRangeNotCovered indicates that the provided range lies outside the time series ErrRangeNotCovered = errors.New("timeseries: range is not convered") )
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock specifies the needed time related functions used by the time series. To use a custom clock implement the interface and pass it to the time series constructor. The default clock uses time.Now()
type Granularity ¶
Granularity describes the granularity for one level of the time series. Count cannot be 0.
type Option ¶
type Option func(*options)
Option configures the time series.
func WithGranularities ¶
func WithGranularities(g []Granularity) Option
WithGranularities returns a Option that sets the granularites used by the time series.
type TimeSeries ¶
type TimeSeries struct {
// contains filtered or unexported fields
}
TimeSeries struct
func NewTimeSeries ¶
func NewTimeSeries(typ TSType, os ...Option) (*TimeSeries, error)
NewTimeSeries creates a new time series with the provided options. If no options are provided default values are used.
func (*TimeSeries) Increase ¶
func (t *TimeSeries) Increase(amount float64)
Increase adds amount at current time.
func (*TimeSeries) IncreaseAtTime ¶
func (t *TimeSeries) IncreaseAtTime(amount float64, time time.Time)
IncreaseAtTime adds amount at a specific time.
func (*TimeSeries) Range ¶
func (t *TimeSeries) Range(start, end time.Time) (float64, error)
Range returns the sum over the given range [start, end). ErrBadRange is returned if start is after end. ErrRangeNotCovered is returned if the range lies outside the time series.
func (*TimeSeries) RangeValues ¶
func (t *TimeSeries) RangeValues(start, end time.Time) ([]PointValue, error)
RangeValues returns the values over the given range [start, end). ErrBadRange is returned if start is after end. ErrRangeNotCovered is returned if the range lies outside the time series.
func (*TimeSeries) Recent ¶
func (t *TimeSeries) Recent(duration time.Duration) (float64, error)
Recent returns the sum over [now-duration, now).
func (*TimeSeries) RecentValues ¶
func (t *TimeSeries) RecentValues(duration time.Duration) ([]PointValue, error)
RecentValues returns the sum over [now-duration, now).