cntdb

package module
v0.4.1-0...-39b9890 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: MIT Imports: 10 Imported by: 0

README

CntDB

Experiment with a dead-simple, little-optimised time series DB for storing counters. Uses Redis as the back-end.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Criteria

type Criteria struct {
	From     time.Time
	Until    time.Time
	Metric   string
	Tags     []string
	Interval time.Duration
}

type DB

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

func NewDB

func NewDB(addr string, db int) *DB

func (*DB) Compact

func (b *DB) Compact(ctx context.Context) error

Compact runs a compaction cycle

func (*DB) Increment

func (b *DB) Increment(points []Point) error

Increment increments point values to the DB

func (*DB) Query

func (b *DB) Query(ctx context.Context, c *Criteria) (ResultSet, error)

func (*DB) QueryPoints

func (b *DB) QueryPoints(ctx context.Context, c *Criteria) ([]Point, error)

QueryPoints performs a query and returns points

func (*DB) QueryStore

func (b *DB) QueryStore(ctx context.Context, targetMetric string, c *Criteria) error

QueryStore performs a query and writes the results to a different metric

func (*DB) Set

func (b *DB) Set(points []Point) error

Set sets point values

type Point

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

func NewPoint

func NewPoint(metric string, tags []string, count int64) (Point, error)

func NewPointAt

func NewPointAt(metric string, tags []string, at time.Time, count int64) (Point, error)

func ParsePoint

func ParsePoint(raw string) (Point, error)

func (Point) Series

func (p Point) Series() string

func (Point) String

func (p Point) String() string

type Result

type Result struct {
	Timestamp time.Time
	Value     int64
}

type ResultSet

type ResultSet []Result

func (ResultSet) Len

func (p ResultSet) Len() int

func (ResultSet) Less

func (p ResultSet) Less(i, j int) bool

func (ResultSet) Swap

func (p ResultSet) Swap(i, j int)

Jump to

Keyboard shortcuts

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