storage

package
v0.0.0-...-070f372 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package storage handles in memory storage and searching for time series elements. Multiple goroutines handle search and storage of time series elements each of which is mapped to a unique key. Keys and associated elements are distributed to goroutines to reduce lock contention.

Index

Constants

View Source
const (

	// DefaultMaxAge default amount of time we keep elements
	DefaultMaxAge = 61 * time.Minute
	// DefaultWorkerCount is the default number of workers to use to handle data
	DefaultWorkerCount = 256
	// DefaultChannelBufferSize is the default buffer size for work channels
	DefaultChannelBufferSize = 100
)

Variables

This section is empty.

Functions

func New

func New(opts Options) *storage

New creates in memory storage for time series data.

Types

type ErrorInvalidSearch

type ErrorInvalidSearch struct{}

func (*ErrorInvalidSearch) Error

func (e *ErrorInvalidSearch) Error() string

func (*ErrorInvalidSearch) InvalidSearch

func (e *ErrorInvalidSearch) InvalidSearch()

type ErrorNotFound

type ErrorNotFound struct {
	Key string
}

func (*ErrorNotFound) Error

func (n *ErrorNotFound) Error() string

func (*ErrorNotFound) NotFound

func (n *ErrorNotFound) NotFound()

type ExpiryHandler

type ExpiryHandler func(key string, elt api.Element)

ExpiryHandler is a callback that will receive time series elements when they expire. This can be used to aggregate and persist old elements.

type InvalidSearch

type InvalidSearch interface {
	InvalidSearch()
}

type KeyNotFound

type KeyNotFound interface {
	NotFound()
}

type Manager

type Manager interface {
	io.Closer
	Searcher
	Writer
}

Manager contains Search, Write and Close.

type Options

type Options struct {
	// MaxAge time series elements older than this will be discarded.
	MaxAge time.Duration
	// WorkerCount is the number of goroutines that process incoming messages.
	WorkerCount int
	// ChannelBufferSize is the number of jobs that can be buffered in the jobs channel to improve throughput and async processing.
	ChannelBufferSize int
	// OnExpire is an optional method that is called when a time series element expires. This could be used to
	// aggregate expiring elements into courser granularity or to write to persistent storage.
	OnExpire ExpiryHandler
	// MessageCounter keeps tally of the number of messages that have arrived.
	MessageCounter metrics.Counter
}

Options for storage of time series.

type Searcher

type Searcher interface {
	Search(key string, first, last uint64) ([]api.Element, error)
}

Searcher returns time series elements associated with key between first and last times. Times are represented as the number of nanoseconds since January 1, 1970 UTC.

type Writer

type Writer interface {
	Write(key string, ts time.Time, data []byte)
}

Writer this that write time series data associated with key at time ts.

Jump to

Keyboard shortcuts

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