datastore

package
v0.0.0-...-4f33e41 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2015 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// NetworkKeyPrefix is the prefix for network key in the kv store
	NetworkKeyPrefix = "network"
)

Variables

View Source
var (
	// ErrNotImplmented exported
	ErrNotImplmented = errors.New("Functionality not implemented")
)

Functions

func Key

func Key(key ...string) string

Key provides convenient method to create a Key

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

func NewCustomDataStore(customStore store.Store) DataStore

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 MockData

type MockData struct {
	Data  []byte
	Index uint64
}

MockData exported

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) Acquire

func (s *MockStore) Acquire(key string, value []byte) (string, error)

Acquire the lock for "key"/"directory"

func (*MockStore) AtomicDelete

func (s *MockStore) AtomicDelete(key string, oldValue []byte, index uint64) (bool, error)

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

func (s *MockStore) AtomicPut(key string, _ []byte, newValue []byte, index uint64) (bool, error)

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

func (s *MockStore) CancelWatch(key string) error

CancelWatch cancels a watch, sends a signal to the appropriate stop channel

func (*MockStore) CancelWatchRange

func (s *MockStore) CancelWatchRange(prefix string) error

CancelWatchRange stops the watch on the range of values, sends a signal to the appropriate stop channel

func (*MockStore) Delete

func (s *MockStore) Delete(key string) error

Delete a value at "key"

func (*MockStore) DeleteRange

func (s *MockStore) DeleteRange(prefix string) error

DeleteRange deletes a range of values at "directory"

func (*MockStore) Exists

func (s *MockStore) Exists(key string) (bool, error)

Exists checks that the key exists inside the store

func (*MockStore) Get

func (s *MockStore) Get(key string) (value []byte, lastIndex uint64, err error)

Get the value at "key", returns the last modified index to use in conjunction to CAS calls

func (*MockStore) GetRange

func (s *MockStore) GetRange(prefix string) (values []store.KVEntry, err error)

GetRange gets a range of values at "directory"

func (*MockStore) Put

func (s *MockStore) Put(key string, value []byte) error

Put a value at "key"

func (*MockStore) Release

func (s *MockStore) Release(id string) error

Release the lock for "key"/"directory"

func (*MockStore) Watch

func (s *MockStore) Watch(key string, heartbeat time.Duration, callback store.WatchCallback) error

Watch a single key for modifications

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"

Jump to

Keyboard shortcuts

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