storage

package
v0.0.0-...-365a2f7 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToFloat

func BytesToFloat(data []byte) float64

BytesToFloat converts a slice of bytes to a float

func FloatToBytes

func FloatToBytes(value float64) []byte

FloatToBytes converts a float64 to bytes

Types

type BoltStorage

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

BoltStorage is an implementation for KeyValueStorage and TimeSeriesStorage

func (*BoltStorage) AddValue

func (store *BoltStorage) AddValue(key string, value float64) error

AddValue saves a value to the given timeseries

func (*BoltStorage) Close

func (store *BoltStorage) Close() error

Close closes the db, flushing it eventually

func (*BoltStorage) Delete

func (store *BoltStorage) Delete(key string) error

Delete drops an entry from db

func (*BoltStorage) DeleteRange

func (store *BoltStorage) DeleteRange(key string, from time.Time, to time.Time) error

DeleteRange deletes a range from a timeseries

func (*BoltStorage) Get

func (store *BoltStorage) Get(key string) ([]byte, error)

Get retrieves a value from db

func (*BoltStorage) GetRange

func (store *BoltStorage) GetRange(key string, from time.Time, to time.Time) (chan *TimeSeriesEntry, error)

GetRange returns a channel which will give all values in a timerange

func (*BoltStorage) Put

func (store *BoltStorage) Put(key string, value []byte) error

Put saves a value to the db

type KeyValueStorage

type KeyValueStorage interface {
	Put(key string, value []byte) error
	Get(key string) ([]byte, error)
	Delete(key string) error
}

KeyValueStorage is the interface for key-value-storage backends

type LevelDBStorage

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

LevelDBStorage is an implementation for KeyValueStorage and TimeSeriesStorage

func NewLevelDBStorage

func NewLevelDBStorage(path string) (*LevelDBStorage, error)

NewLevelDBStorage creates a new storage instance

func (*LevelDBStorage) AddValue

func (store *LevelDBStorage) AddValue(key string, value float64) error

AddValue saves a value to the given timeseries

func (*LevelDBStorage) Close

func (store *LevelDBStorage) Close() error

Close closes the db, flushing it eventually

func (*LevelDBStorage) Delete

func (store *LevelDBStorage) Delete(key string) error

Delete drops an entry from db

func (*LevelDBStorage) DeleteRange

func (store *LevelDBStorage) DeleteRange(key string, from time.Time, to time.Time) error

func (*LevelDBStorage) Get

func (store *LevelDBStorage) Get(key string) ([]byte, error)

Get retrieves a value from db

func (*LevelDBStorage) GetRange

func (store *LevelDBStorage) GetRange(key string, from time.Time, to time.Time) (chan *TimeSeriesEntry, error)

GetRange returns a channel which will give all values in a timerange

func (*LevelDBStorage) Put

func (store *LevelDBStorage) Put(key string, value []byte) error

Put saves a value to the db

type MetaStorage

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

MetaStorage wraps a specific storage

func (*MetaStorage) AddValue

func (store *MetaStorage) AddValue(key string, value float64) error

func (*MetaStorage) Close

func (store *MetaStorage) Close() error

func (*MetaStorage) Delete

func (store *MetaStorage) Delete(key string) error

func (*MetaStorage) DeleteRange

func (store *MetaStorage) DeleteRange(key string, from time.Time, to time.Time) error

func (*MetaStorage) Get

func (store *MetaStorage) Get(key string) ([]byte, error)

func (*MetaStorage) GetRange

func (store *MetaStorage) GetRange(key string, from time.Time, to time.Time) (chan *TimeSeriesEntry, error)

func (*MetaStorage) Put

func (store *MetaStorage) Put(key string, value []byte) error

type MongoStorage

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

MongoStorage is an implementation for KeyValueStorage and TimeSeriesStorage

func (*MongoStorage) AddValue

func (store *MongoStorage) AddValue(key string, value float64) error

AddValue adds a value to a timeseries

func (*MongoStorage) Close

func (store *MongoStorage) Close() error

Close closes the db

func (*MongoStorage) Delete

func (store *MongoStorage) Delete(key string) error

Delete drops an entry from db

func (*MongoStorage) DeleteRange

func (store *MongoStorage) DeleteRange(key string, from time.Time, to time.Time) error

DeleteRange returns a aspecific range in a timeseries

func (*MongoStorage) Get

func (store *MongoStorage) Get(key string) ([]byte, error)

Get retrieves a doc from the db

func (*MongoStorage) GetRange

func (store *MongoStorage) GetRange(key string, from time.Time, to time.Time) (chan *TimeSeriesEntry, error)

GetRange returns a aspecific range in a timeseries

func (*MongoStorage) Put

func (store *MongoStorage) Put(key string, value []byte) error

Put stores data in the db seperate collections can be specified by using slashes in the key -> Put("foo/bar", "baz") will create a doc with key bar in collection foo (containing baz)

type Storage

type Storage interface {
	KeyValueStorage
	TimeSeriesStorage
	Close() error
}

Storage is a combined interface of KeyValueStorage and TimeSeriesStorage

func NewBoltStorage

func NewBoltStorage(path string) (Storage, error)

NewBoltStorage creates a new storage instance

func NewMetaStorage

func NewMetaStorage(uriStr string) (Storage, error)

NewMetaStorage returns a new Storage object with the correct implementation for the given URI

func NewMongoStorage

func NewMongoStorage(url string) (Storage, error)

NewMongoStorage creates a new storage with mongodb as its backend

type TimeSeriesEntry

type TimeSeriesEntry struct {
	Value     float64
	Timestamp time.Time
}

A TimeSeriesEntry is a single entry of a timeseries

type TimeSeriesStorage

type TimeSeriesStorage interface {
	AddValue(key string, value float64) error
	GetRange(key string, from time.Time, to time.Time) (chan *TimeSeriesEntry, error)
	DeleteRange(key string, from time.Time, to time.Time) error
}

TimeSeriesStorage is the interface for timeseries handling

Jump to

Keyboard shortcuts

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