tsdb

package module
v0.0.0-...-2f8c6a0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: MIT Imports: 9 Imported by: 1

README

lite.tsdb GoDoc Build Status

A Go library for storing timeseries data in a key value store. Currently the keyvalue store is boltdb

Documentation

Index

Constants

View Source
const (
	ASC  = "asc"
	DESC = "desc"
)

Variables

View Source
var (
	ErrSeriesNotFound = errors.New("timeseries not found")
)

Functions

This section is empty.

Types

type BoltDBConfig

type BoltDBConfig struct {
	Path string
	Mode os.FileMode
}

type Boltdb

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

func (Boltdb) Add

func (bdb Boltdb) Add(name string, timeseries TimeSeries) error

func (Boltdb) Close

func (bdb Boltdb) Close() error

func (Boltdb) Create

func (bdb Boltdb) Create(name string) error

func (Boltdb) Delete

func (bdb Boltdb) Delete(series string) error

func (Boltdb) Get

func (bdb Boltdb) Get(series string) (TimeSeries, error)

func (Boltdb) GetOnChannel

func (bdb Boltdb) GetOnChannel(series string) (<-chan TimeEntry, chan error)

func (Boltdb) GetPages

func (bdb Boltdb) GetPages(q Query) ([]int64, int, error)

func (Boltdb) Query

func (bdb Boltdb) Query(q Query) (timeSeries TimeSeries, nextEntry *int64, err error)

func (Boltdb) QueryOnChannel

func (bdb Boltdb) QueryOnChannel(q Query) (<-chan TimeEntry, chan *int64, chan error)

type Query

type Query struct {
	Series string

	From int64
	To   int64
	//Sorting order:
	//Possible values are ASC and DESC
	//ASC : The time Series will have the oldest data first
	//DESC: The time Series will have the latest  data first.
	Sort string

	//Number of entries to be returned per page. This is used for pagination.
	// The next sequence is found out using NextEntry variable of a query response.
	MaxEntries int
}

type TSDB

type TSDB interface {

	//Create a new bucket
	Create(name string) error

	//This function adds the senml records
	Add(name string, timeseries TimeSeries) error

	//Get the senml records
	Query(q Query) (timeSeries TimeSeries, nextEntry *int64, err error)

	QueryOnChannel(q Query) (timeseries <-chan TimeEntry, nextEntry chan *int64, err chan error)
	//Get the total pages for a particular query.
	// This helps for any client to call multiple queries
	GetPages(q Query) (seriesList []int64, count int, err error)

	//Get the senml records
	Get(series string) (timeSeries TimeSeries, err error)
	//Returns two channels, one for Time entries and one for error.
	//This avoids the usage of an extra buffer by the database
	//Caution: first read the channel and then read the error. Error channel shall be written only after the timeseries channel is closed
	GetOnChannel(series string) (timeseries <-chan TimeEntry, err chan error)

	//Delete a complete Series
	Delete(series string) error

	//Close the database
	Close() error
}

func Open

func Open(config interface{}) (TSDB, error)

type TimeEntry

type TimeEntry struct {
	Time  int64
	Value []byte
}

type TimeSeries

type TimeSeries []TimeEntry

Jump to

Keyboard shortcuts

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