storage

package
v1.1.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: MIT Imports: 9 Imported by: 136

Documentation

Overview

The storage package provides a key/value based interface for storing Kapacitor metadata. All services wishing to store data should use this interface.

The usage patterns for this storage layer are typical create/replace/delete/get/list operations. Typically objects are serialized and stored as the value. As a result, updates to a single field of an object can incur the cost to retrieve the entire object and store it again. In most cases this is acceptable since modifications are rare and object size is small.

A BoltDB backed implementation is also provided.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoKeyExists = errors.New("no key exists")
)

Common errors that can be returned

Functions

func DoListFunc

func DoListFunc(list []*KeyValue, match func(value []byte) bool, offset, limit int) [][]byte

Return a list of values from a list of KeyValues using an offset/limit bound and a match function.

Types

type Bolt

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

Bolt implementation of Store

func NewBolt

func NewBolt(db *bolt.DB, bucket string) *Bolt

func (*Bolt) Delete

func (b *Bolt) Delete(key string) error

func (*Bolt) Exists

func (b *Bolt) Exists(key string) (bool, error)

func (*Bolt) Get

func (b *Bolt) Get(key string) (*KeyValue, error)

func (*Bolt) List

func (b *Bolt) List(prefix string) (kvs []*KeyValue, err error)

func (*Bolt) Put

func (b *Bolt) Put(key string, value []byte) error

type Config

type Config struct {
	// Path to a boltdb database file.
	BoltDBPath string `toml:"boltdb"`
}

func NewConfig

func NewConfig() Config

func (Config) Validate

func (c Config) Validate() error

type Interface

type Interface interface {
	// Store a value.
	Put(key string, value []byte) error
	// Retrieve a value.
	Get(key string) (*KeyValue, error)
	// Delete a key.
	// Deleting a non-existent key is not an error.
	Delete(key string) error
	// Check if a key exists>
	Exists(key string) (bool, error)
	// List all values with given prefix.
	List(prefix string) ([]*KeyValue, error)
}

Common interface for interacting with a simple Key/Value storage

type KeyValue

type KeyValue struct {
	Key   string
	Value []byte
}

type Service

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

func NewService

func NewService(conf Config, l *log.Logger) *Service

func (*Service) Close

func (s *Service) Close() error

func (*Service) Open

func (s *Service) Open() error

func (*Service) Store

func (s *Service) Store(name string) Interface

Return a namespaced store. Calling Store with the same namespace returns the same Store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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