storage

package
v0.0.0-...-8c342a6 Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStorageSnapshotInterval = 1 * time.Minute

DefaultStorageSnapshotInterval is the default interval, in which snapshots are being stored to disks in the storage.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encode(value interface{}) (data []byte, err error)
	Decode(data []byte) (value interface{}, err error)
}

Codec decodes and encodes from and to []byte

type Iterator

type Iterator interface {
	// Next advances the iterator to the next key.
	Next() bool
	// Key gets the current key. If the iterator is exhausted, key will return
	// nil.
	Key() []byte
	// Value gets the current value. Value is decoded with the codec given to the
	// storage.
	Value() (interface{}, error)
	// Release releases the iterator. After release, the iterator is not usable
	// anymore.
	Release()
}

Iterator provides iteration access to the stored values.

type Storage

type Storage interface {
	Has(string) (bool, error)
	Get(string) (interface{}, error)
	Set(string, interface{}) error
	SetEncoded(string, []byte) error
	Delete(string) error
	SetOffset(value int64) error
	GetOffset(defValue int64) (int64, error)
	Iterator() Iterator
	Open() error
	Close() error
	Sync()
}

Storage abstracts the interface for a persistent local storage

func New

func New(fn string, c Codec, m metrics.Registry, snapshotInterval time.Duration) (Storage, error)

New news new

func NewMock

func NewMock(c Codec) Storage

NewMock creates a mock storage for testing

Jump to

Keyboard shortcuts

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