datastore

package module
v0.0.0-...-17956ee Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 6 Imported by: 0

README

senml.datastore GoDoc Build Status

A datastore to keep SenML (Sensor Measurement Lists based on RFC8428) data in time series database. Currently this uses BoltDB as the database

Documentation

Index

Constants

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

Variables

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

Functions

func FromSenmlTime

func FromSenmlTime(t float64) time.Time

func ToSenmlTime

func ToSenmlTime(t time.Time) float64

Types

type DenormMask

type DenormMask int
const (
	FName DenormMask = 1 << iota
	FTime
	FUnit
	FValue
	FSum
)

type Query

type Query struct {
	//A comma separated senml names
	Series string

	From float64
	To   float64
	//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 request. This is used for pagination. The next sequence is found out using NextEntry function
	MaxEntries int

	//comma separated fields for denormalization (see https://tools.ietf.org/html/rfc8428#section-4.6). Currently only "name" and "time" are supported.
	Denormalize DenormMask
}

type SenMLDBRecord

type SenMLDBRecord struct {
	Unit        string   `json:"u,omitempty" `
	UpdateTime  float64  `json:"ut,omitempty"`
	Value       *float64 `json:"v,omitempty" `
	StringValue string   `json:"vs,omitempty" `
	DataValue   string   `json:"vd,omitempty"  `
	BoolValue   *bool    `json:"vb,omitempty" `

	Sum *float64 `json:"s,omitempty" `
}

func NewBoltSenMLRecord

func NewBoltSenMLRecord(record senml.Record) SenMLDBRecord

type SenmlDataStore

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

func (SenmlDataStore) Add

func (bdb SenmlDataStore) Add(senmlPack senml.Pack) error

func (*SenmlDataStore) Connect

func (bdb *SenmlDataStore) Connect(path string) error

func (SenmlDataStore) Create

func (bdb SenmlDataStore) Create(name string) error

Create a new bucket

func (*SenmlDataStore) Delete

func (bdb *SenmlDataStore) Delete(series string) error

func (SenmlDataStore) Disconnect

func (bdb SenmlDataStore) Disconnect() error

func (SenmlDataStore) Get

func (bdb SenmlDataStore) Get(series string) (senml.Pack, error)

func (SenmlDataStore) GetPages

func (bdb SenmlDataStore) GetPages(query Query) ([]float64, int, error)

func (SenmlDataStore) Query

func (bdb SenmlDataStore) Query(query Query) (senml.Pack, *float64, error)

Query the data store for a particular range. This gives the response in multiple pages

Jump to

Keyboard shortcuts

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