storage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: BSD-3-Clause Imports: 12 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder func(topic string, partition int32) (Storage, error)

Builder creates a local storage (a persistent cache) for a topic table. Builder creates one storage for each partition of the topic.

func BuilderWithOptions

func BuilderWithOptions(path string, opts *opt.Options) Builder

BuilderWithOptions builds LevelDB storage with the given options and in the given path.

func DefaultBuilder

func DefaultBuilder(path string) Builder

DefaultBuilder builds a LevelDB storage with default configuration. The database will be stored in the given path.

func MemoryBuilder

func MemoryBuilder() Builder

MemoryBuilder builds in-memory storage.

type Iterator

type Iterator interface {
	// Next advances the iterator to the next key.
	Next() bool
	// Err should be called after Next returns false to check for possible
	// iteration errors.
	Err() error
	// Key gets the current key. If the iterator is exhausted, key will return
	// nil.
	Key() []byte
	// Value gets the current value.
	Value() ([]byte, error)
	// Release releases the iterator. After release, the iterator is not usable
	// anymore.
	Release()
	// Seek for a key in the iterator
	Seek(key []byte) bool
}

Iterator provides iteration access to the stored values.

func NewMultiIterator

func NewMultiIterator(iters []Iterator) Iterator

NewMultiIterator returns an Iterator that iterates over the given subiterators. Iteration happens in lexicographical order given that the subiterators also return values in order.

type Null

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

Null storage discards everything that it is given. This can be useful for debugging.

func (*Null) Close

func (n *Null) Close() error

Close does nothing and doesn't error

func (*Null) Delete

func (n *Null) Delete(string) error

Delete does nothing and doesn't error.

func (*Null) Get

func (n *Null) Get(key string) ([]byte, error)

Get returns nil values.

func (*Null) GetOffset

func (n *Null) GetOffset(def int64) (int64, error)

GetOffset returns the default offset given to it.

func (*Null) Has

func (n *Null) Has(key string) (bool, error)

Has returns false as in key not found.

func (*Null) Iterator

func (n *Null) Iterator() (Iterator, error)

Iterator returns an Iterator that is immediately exhausted.

func (*Null) IteratorWithRange

func (n *Null) IteratorWithRange(start, limit []byte) (Iterator, error)

IteratorWithRange returns an Iterator that is immediately exhausted.

func (*Null) MarkRecovered

func (n *Null) MarkRecovered() error

MarkRecovered does nothing.

func (*Null) Open

func (n *Null) Open() error

Open does nothing and doesn't error.

func (*Null) Recovered

func (n *Null) Recovered() bool

Recovered returns whether the storage has recovered.

func (*Null) Set

func (n *Null) Set(key string, val []byte) error

Set will do nothing and doesn't error.

func (*Null) SetOffset

func (n *Null) SetOffset(val int64) error

SetOffset does nothing and doesn't error.

type NullIter

type NullIter struct{}

NullIter is an iterator which is immediately exhausted.

func (*NullIter) Err added in v0.1.2

func (*NullIter) Err() error

func (*NullIter) Key

func (ni *NullIter) Key() []byte

Key returns always nil.

func (*NullIter) Next

func (ni *NullIter) Next() bool

Next returns always false.

func (*NullIter) Release

func (ni *NullIter) Release()

Release does nothing.

func (*NullIter) Seek

func (ni *NullIter) Seek(key []byte) bool

Seek do nothing

func (*NullIter) Value

func (ni *NullIter) Value() ([]byte, error)

Value returns always a nil value and no errors.

type Storage

type Storage interface {
	Has(string) (bool, error)
	Get(string) ([]byte, error)
	Set(string, []byte) error
	Delete(string) error
	SetOffset(value int64) error
	GetOffset(defValue int64) (int64, error)
	Iterator() (Iterator, error)
	IteratorWithRange(start, limit []byte) (Iterator, error)
	MarkRecovered() error
	Recovered() bool
	Open() error
	Close() error
}

Storage abstracts the interface for a persistent local storage

func New

func New(db *leveldb.DB) (Storage, error)

New creates a new Storage backed by LevelDB.

func NewFile

func NewFile(path string, part int32) (Storage, error)

NewFile retuns a new on-disk storage.

func NewMemory

func NewMemory() Storage

NewMemory returns a new in-memory storage.

func NewNull

func NewNull() Storage

NewNull returns a new Null storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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