Documentation
¶
Index ¶
- Constants
- Variables
- func Key(key ...string) string
- type DataStore
- type KV
- type MockData
- type MockStore
- func (s *MockStore) Acquire(key string, value []byte) (string, error)
- func (s *MockStore) AtomicDelete(key string, oldValue []byte, index uint64) (bool, error)
- func (s *MockStore) AtomicPut(key string, _ []byte, newValue []byte, index uint64) (bool, error)
- func (s *MockStore) CancelWatch(key string) error
- func (s *MockStore) CancelWatchRange(prefix string) error
- func (s *MockStore) Delete(key string) error
- func (s *MockStore) DeleteRange(prefix string) error
- func (s *MockStore) Exists(key string) (bool, error)
- func (s *MockStore) Get(key string) (value []byte, lastIndex uint64, err error)
- func (s *MockStore) GetRange(prefix string) (values []store.KVEntry, err error)
- func (s *MockStore) Put(key string, value []byte) error
- func (s *MockStore) Release(id string) error
- func (s *MockStore) Watch(key string, heartbeat time.Duration, callback store.WatchCallback) error
- func (s *MockStore) WatchRange(prefix string, filter string, heartbeat time.Duration, ...) error
Constants ¶
const (
// NetworkKeyPrefix is the prefix for network key in the kv store
NetworkKeyPrefix = "network"
)
Variables ¶
var ( // ErrNotImplmented exported ErrNotImplmented = errors.New("Functionality not implemented") )
Functions ¶
Types ¶
type DataStore ¶
type DataStore interface {
// PutObject adds a new Record based on an object into the datastore
PutObject(kvObject KV) error
// PutObjectAtomic provides an atomic add and update operation for a Record
PutObjectAtomic(kvObject KV) error
// KVStore returns access to the KV Store
KVStore() store.Store
}
DataStore exported
func NewCustomDataStore ¶
NewCustomDataStore can be used by clients to plugin cusom datatore that adhers to store.Store
func NewDataStore ¶
func NewDataStore(cfg *config.DatastoreCfg) (DataStore, error)
NewDataStore creates a new instance of LibKV data store
type KV ¶
type KV interface {
// Key method lets an object to provide the Key to be used in KV Store
Key() []string
// Value method lets an object to marshal its content to be stored in the KV store
Value() []byte
// Index method returns the latest DB Index as seen by the object
Index() uint64
// SetIndex method allows the datastore to store the latest DB Index into the object
SetIndex(uint64)
}
KV Key Value interface used by objects to be part of the DataStore
type MockStore ¶
type MockStore struct {
// contains filtered or unexported fields
}
MockStore exported
func NewMockStore ¶
func NewMockStore() *MockStore
NewMockStore creates a Map backed Datastore that is useful for mocking
func (*MockStore) 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 (*MockStore) AtomicPut ¶
AtomicPut put a value at "key" if the key has not been modified in the meantime, throws an error if this is the case
func (*MockStore) CancelWatch ¶
CancelWatch cancels a watch, sends a signal to the appropriate stop channel
func (*MockStore) CancelWatchRange ¶
CancelWatchRange stops the watch on the range of values, sends a signal to the appropriate stop channel
func (*MockStore) DeleteRange ¶
DeleteRange deletes a range of values at "directory"
func (*MockStore) Get ¶
Get the value at "key", returns the last modified index to use in conjunction to CAS calls
func (*MockStore) WatchRange ¶
func (s *MockStore) WatchRange(prefix string, filter string, heartbeat time.Duration, callback store.WatchCallback) error
WatchRange triggers a watch on a range of values at "directory"