Documentation
¶
Index ¶
- type Builder
- type Iterator
- type Null
- func (n *Null) Close() error
- func (n *Null) Delete(string) error
- func (n *Null) Get(key string) ([]byte, error)
- func (n *Null) GetOffset(def int64) (int64, error)
- func (n *Null) Has(key string) (bool, error)
- func (n *Null) Iterator() (Iterator, error)
- func (n *Null) IteratorWithRange(start, limit []byte) (Iterator, error)
- func (n *Null) MarkRecovered() error
- func (n *Null) Open() error
- func (n *Null) Recovered() bool
- func (n *Null) Set(key string, val []byte) error
- func (n *Null) SetOffset(val int64) error
- type NullIter
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
Builder creates a local storage (a persistent cache) for a topic table. Builder creates one storage for each partition of the topic.
func BuilderWithOptions ¶
BuilderWithOptions builds LevelDB storage with the given options and in the given path.
func DefaultBuilder ¶
DefaultBuilder builds a LevelDB storage with default configuration. The database will be stored in the given path.
type Iterator ¶
type Iterator interface {
// Next moves the iterator to the next key-value pair and whether such a pair
// exists. Caller should check for possible error by calling Error after Next
// returns false.
Next() bool
// Err returns the error that stopped the iteration if any.
Err() error
// Key returns the current key. Caller should not keep references to the
// buffer or modify its contents.
Key() []byte
// Value returns the current value. Caller should not keep references to the
// buffer or modify its contents.
Value() ([]byte, error)
// Release releases the iterator. After release, the iterator is not usable
// anymore.
Release()
// Seek moves the iterator to the begining of a key-value pair sequence that
// is greater or equal to the given key. It returns whether at least one of
// such key-value pairs exist. Next must be called after seeking to access
// the first pair.
Seek(key []byte) bool
}
Iterator provides iteration access to the stored values.
func NewMultiIterator ¶
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) IteratorWithRange ¶
IteratorWithRange returns an Iterator that is immediately exhausted.
type Storage ¶
type Storage interface {
// Opens/Initialize the storage
Open() error
// Close closes the storage.
Close() error
// Has returns whether the given key exists in the database.
Has(key string) (bool, error)
// Get returns the value associated with the given key. If the key does not
// exist, a nil will be returned.
Get(key string) ([]byte, error)
// Set stores a key-value pair.
Set(key string, value []byte) error
// Delete deletes a key-value pair from the storage.
Delete(key string) error
// GetOffset gets the local offset of the storage.
GetOffset(def int64) (int64, error)
// SetOffset sets the local offset of the storage.
SetOffset(offset int64) error
// MarkRecovered marks the storage as recovered. Recovery message throughput
// can be a lot higher than during normal operation. This can be used to switch
// to a different configuration after the recovery is done.
MarkRecovered() error
// Iterator returns an iterator that traverses over a snapshot of the storage.
Iterator() (Iterator, error)
// Iterator returns a new iterator that iterates over the key-value
// pairs. Start and limit define a half-open range [start, limit). If either
// is nil, the range will be unbounded on the respective side.
IteratorWithRange(start, limit []byte) (Iterator, error)
}
Storage is the interface Goka expects from a storage implementation. Implementations of this interface must be safe for any number of concurrent readers with one writer.