tskv

package module
v0.0.0-...-380a624 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2016 License: AGPL-3.0 Imports: 3 Imported by: 0

README

go-tskv

Go library for Time Series Key Value storage.

Build Status Coverage Status Go Report Card

Usage

package main

import (
	"fmt"

	"github.com/brimstone/go-tskv"
)

func main() {
	weight, err := tskv.New(tskv.Config{
		Duration:  time.Hour,
		Frequency: time.Minute,
	})
	if err != nil {
		panic(err)
	}
	weight.InsertNow(100)
	fmt.Println("Last weight:", weight.Last().Int())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Duration  time.Duration
	Frequency time.Duration
}

Config holds our main configuration information

type Element

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

Element Smallest Atom

func (*Element) Int

func (e *Element) Int() int

Int returns integer form of Element

func (*Element) Value

func (e *Element) Value() interface{}

Value returns integer form of Element

type Tskv

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

Tskv our main structure

func New

func New(config Config) (*Tskv, error)

New Returns a brand new Tskv object

func (*Tskv) GetInt

func (t *Tskv) GetInt() []int

GetInt returns and integer representation of the series

func (*Tskv) GetMap

func (t *Tskv) GetMap() map[time.Time]Element

GetMap returns an raw representation of the series

func (*Tskv) GetRaw

func (t *Tskv) GetRaw() []Element

GetRaw returns an raw representation of the series

func (*Tskv) GetSince

func (t *Tskv) GetSince(when time.Time) *Tskv

GetSince Returns all of the elements

func (*Tskv) Inc

func (t *Tskv) Inc(when time.Time, value interface{}) error

Inc increments an element to our tskv

func (*Tskv) IncNow

func (t *Tskv) IncNow(value interface{}) error

IncNow increments an element to our tskv, at the current time

func (*Tskv) Last

func (t *Tskv) Last() *Element

Last returns the youngest element in our tskv

func (*Tskv) MarshalJSON

func (t *Tskv) MarshalJSON() ([]byte, error)

MarshalJSON provides an interface for json.Marshal

func (*Tskv) Oldest

func (t *Tskv) Oldest() *Element

Oldest returns the oldest element in our tskv

func (*Tskv) Set

func (t *Tskv) Set(when time.Time, value interface{}) error

Set Sets an element to our tskv

func (*Tskv) SetNow

func (t *Tskv) SetNow(value interface{}) error

SetNow Sets an element to our tskv, at the current time

func (*Tskv) Subscribe

func (t *Tskv) Subscribe() chan *Tskv

Subscribe returns a new channel in which updates to the tskv are sent

Jump to

Keyboard shortcuts

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