statedb

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package statedb handles the states storage on LevelDB.

Design

The db file name is state-NumGridxGirdLen, and the key-value design in leveldb is:

Key:   <Name>:<GridNo>
Value: <Average>:<StdDev>:<Count>

The GridNo is computed by:

GirdNo = (Stamp % Period) / GirdLen

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when requested data not found.
	ErrNotFound = errors.New("statedb: not found")
	// ErrCorrupted is returned when corrupted data found.
	ErrCorrupted = errors.New("statedb: corrupted data found")
)

Functions

This section is empty.

Types

type DB

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

DB handles the states storage for detection.

func Open

func Open(fileName string, options *Options) (*DB, error)

Open a DB by fileName and options.

func (*DB) Close

func (db *DB) Close() error

Close the DB.

func (*DB) Delete

func (db *DB) Delete(name string) error

Delete all states for a metric name. This operation is currently only used for cleaning.

func (*DB) Get

func (db *DB) Get(m *models.Metric) (*models.State, error)

Get the State for the given Metric.

func (*DB) Put

func (db *DB) Put(m *models.Metric, s *models.State) error

Put the State for the given Metric.

type Options

type Options struct {
	NumGrid uint32
	GridLen uint32
}

Options is for db opening.

Jump to

Keyboard shortcuts

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