timeserie

package
v0.0.0-...-33d3dc2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultClock = &defaultClock{}
)

Functions

func ReducerLatestValue

func ReducerLatestValue(current int, newValue int) int

func TickByDay

func TickByDay(t time.Time, ticksDelta int) time.Time

Types

type Clock

type Clock interface {
	Now() time.Time
}

type Entry

type Entry struct {
	Time  time.Time
	Value int
}

type Interval

type Interval int
const (
	IntervalMonth Interval = iota
	IntervalWeek
	IntervalDay
	IntervalHour
	Interval10m
	IntervalMinute
)

type Options

type Options struct {
	Clock        Clock
	Ticker       Ticker
	Length       int
	DefaultValue int
	ValueReducer ValueReducer
}

type Ticker

type Ticker func(t time.Time, pos int) time.Time

func TickByHours

func TickByHours(hoursPerTick int) Ticker

func TickByMinutes

func TickByMinutes(minutesPerTick int) Ticker

func TickBySeconds

func TickBySeconds(secondsPerTick int) Ticker

type Timeserie

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

func New

func New(opt Options) (*Timeserie, error)

func (*Timeserie) Get

func (ts *Timeserie) Get() []Entry

func (*Timeserie) Insert

func (ts *Timeserie) Insert(value int)

func (*Timeserie) Length

func (t *Timeserie) Length() int

type ValueReducer

type ValueReducer func(current int, newValue int) int

Jump to

Keyboard shortcuts

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