Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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 ¶
func NewTimeSeries ¶
func NewTimeSeries(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 int)
Increase adds amount at current time.
func (*TimeSeries) IncreaseAtTime ¶
func (t *TimeSeries) IncreaseAtTime(amount int, time time.Time)
IncreaseAtTime adds amount at a specific time.
Click to show internal directories.
Click to hide internal directories.