Documentation
¶
Overview ¶
Package boltstore is the chassis's boltdb backend for the op-writable KV (txco://kv/*), registered with valkeyrie under the same "boltdb" name the default TXCO_KVSTORE selects.
It is a vendored derivative of github.com/kvtools/boltdb v1.0.2 (Apache License 2.0 — see LICENSE.kvtools-boltdb in this directory), taken in-tree so the chassis can run several reads or writes in ONE transaction: upstream keeps its *bbolt.DB private, and store.Store has no batch operation. The on-disk format is unchanged (an 8-byte little-endian index before each value), so an existing store opens as-is. Changes from upstream, per Apache-2.0 §4(b):
- Added GetMulti, PutMulti and DeleteMulti: a positional batch read and all-or-nothing batch writes, each in one bbolt transaction, which chassis/kv discovers by interface to serve txco://kv/mget, kv/mset and kv/mdelete.
- Package renamed boltdb → boltstore. StoreName, Config, New and Store keep their names, so importers alias the package as boltdb.
Index ¶
- Constants
- Variables
- type Config
- type Store
- func (b *Store) AtomicDelete(_ context.Context, key string, previous *store.KVPair) (bool, error)
- func (b *Store) AtomicPut(_ context.Context, key string, value []byte, previous *store.KVPair, ...) (bool, *store.KVPair, error)
- func (b *Store) Close() error
- func (b *Store) Delete(_ context.Context, key string) error
- func (b *Store) DeleteMulti(_ context.Context, keys []string) error
- func (b *Store) DeleteTree(_ context.Context, keyPrefix string) error
- func (b *Store) Exists(_ context.Context, key string, _ *store.ReadOptions) (bool, error)
- func (b *Store) Get(_ context.Context, key string, _ *store.ReadOptions) (*store.KVPair, error)
- func (b *Store) GetMulti(_ context.Context, keys []string) ([]*store.KVPair, error)
- func (b *Store) List(_ context.Context, keyPrefix string, _ *store.ReadOptions) ([]*store.KVPair, error)
- func (b *Store) NewLock(_ context.Context, _ string, _ *store.LockOptions) (store.Locker, error)
- func (b *Store) Put(_ context.Context, key string, value []byte, _ *store.WriteOptions) error
- func (b *Store) PutMulti(_ context.Context, pairs []*store.KVPair, _ []*store.WriteOptions) error
- func (b *Store) Watch(_ context.Context, _ string, _ *store.ReadOptions) (<-chan *store.KVPair, error)
- func (b *Store) WatchTree(_ context.Context, _ string, _ *store.ReadOptions) (<-chan []*store.KVPair, error)
Constants ¶
const StoreName = "boltdb"
StoreName the name of the store.
Variables ¶
var ( // ErrMultipleEndpointsUnsupported is thrown when multiple endpoints specified for BoltDB. // Endpoint has to be a local file path. ErrMultipleEndpointsUnsupported = errors.New("boltdb supports one endpoint and should be a file path") // ErrBoltBucketOptionMissing is thrown when boltBucket config option is missing. ErrBoltBucketOptionMissing = errors.New("boltBucket config option missing") )
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// By default, valkeyrie opens and closes the BoltDB connection for every get/put operation.
// This allows multiple apps to use a BoltDB at the same time.
// PersistConnection flag provides an option to override ths behavior.
// ie: open the connection in New and use it till Close is called.
PersistConnection bool
// contains filtered or unexported fields
}
Store implements the store.Store interface.
func (*Store) AtomicDelete ¶
AtomicDelete deletes a value at "key" if the key has not been modified in the meantime, throws an error if this is the case.
func (*Store) AtomicPut ¶
func (b *Store) AtomicPut(_ context.Context, key string, value []byte, previous *store.KVPair, _ *store.WriteOptions) (bool, *store.KVPair, error)
AtomicPut puts a value at "key" if the key has not been modified since the last Put, throws an error if this is the case.
func (*Store) DeleteMulti ¶
DeleteMulti removes keys in ONE transaction — all or none. A missing key, or a bucket not yet created, is not an error.
func (*Store) DeleteTree ¶
DeleteTree deletes a range of keys with a given prefix.
func (*Store) Get ¶
Get the value at "key". BoltDB doesn't provide an inbuilt last modified index with every kv pair. It's implemented by an atomic counter maintained by the valkeyrie and appended to the value passed by the client.
func (*Store) GetMulti ¶
GetMulti reads keys in ONE read transaction and returns one pair per key, positionally, nil where the key is missing — a single file open for a whole kv/mget instead of one per key.
func (*Store) List ¶
func (b *Store) List(_ context.Context, keyPrefix string, _ *store.ReadOptions) ([]*store.KVPair, error)
List returns the range of keys starting with the passed in prefix.
func (*Store) NewLock ¶
NewLock has to implemented at the library level since it's not supported by BoltDB.
func (*Store) PutMulti ¶
PutMulti writes pairs in ONE transaction: every pair lands or, on any error, none does — bbolt rolls the whole transaction back. opts is ignored, as Put ignores it: BoltDB has no native expiry (chassis/kv's value wrapper carries its own).