Documentation
¶
Overview ¶
Package store is the control-plane state store (FR-CORE-032): a small transactional, namespaced key-value interface with an in-memory implementation for --ephemeral and a bbolt (pure Go) one for --data-dir.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("store: not found")
ErrNotFound is returned by GetJSON when a key is absent.
Functions ¶
Types ¶
type Bolt ¶
type Bolt struct {
// contains filtered or unexported fields
}
Bolt is a crash-safe file-backed Store built on bbolt.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-memory Store. Update transactions are serialised and rolled back on error using an undo log.
type Store ¶
type Store interface {
View(fn func(Tx) error) error
Update(fn func(Tx) error) error
// Reset deletes every namespace.
Reset() error
// Dump returns every namespace's contents (for snapshots and admin dumps).
Dump() (map[string]map[string][]byte, error)
// Load replaces all contents with data.
Load(data map[string]map[string][]byte) error
Close() error
}
Store is a transactional namespaced KV store. Keys within a namespace are iterated in byte order.
type Tx ¶
type Tx interface {
Get(ns, key string) ([]byte, bool)
Put(ns, key string, val []byte) error
Delete(ns, key string) error
// Scan calls fn for every key in ns with the given prefix, in order,
// until fn returns false.
Scan(ns, prefix string, fn func(key string, val []byte) bool)
}
Tx is a store transaction. Writes on a View transaction return an error.