Documentation ¶
Index ¶
- Constants
- Variables
- func Key(key ...string) string
- type KVObject
- type ScopeCfg
- type ScopeClientCfg
- type Store
- func (ds *Store) Close()
- func (ds *Store) DeleteObject(kvObject KVObject) error
- func (ds *Store) DeleteObjectAtomic(kvObject KVObject) error
- func (ds *Store) GetObject(o KVObject) error
- func (ds *Store) List(kvObject KVObject) ([]KVObject, error)
- func (ds *Store) Map(key string, kvObject KVObject) (map[string]KVObject, error)
- func (ds *Store) PutObjectAtomic(kvObject KVObject) error
Constants ¶
const ( // NetworkKeyPrefix is the prefix for network key in the kv store NetworkKeyPrefix = "network" // EndpointKeyPrefix is the prefix for endpoint key in the kv store EndpointKeyPrefix = "endpoint" )
Variables ¶
var ( ErrKeyModified = store.ErrKeyModified ErrKeyNotFound = store.ErrKeyNotFound )
ErrKeyModified is raised for an atomic update when the update is working on a stale state
Functions ¶
Types ¶
type KVObject ¶
type KVObject interface { // Key method lets an object provide the Key to be used in KV Store Key() []string // KeyPrefix method lets an object return immediate parent key that can be used for tree walk KeyPrefix() []string // Value method lets an object marshal its content to be stored in the KV store Value() []byte // SetValue is used by the datastore to set the object's value when loaded from the data store. SetValue([]byte) error // 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) // Exists returns true if the object exists in the datastore, false if it hasn't been stored yet. // When SetIndex() is called, the object has been stored. Exists() bool // Skip provides a way for a KV Object to avoid persisting it in the KV Store Skip() bool // New returns a new object which is created based on the // source object New() KVObject // CopyTo deep copies the contents of the implementing object // to the passed destination object CopyTo(KVObject) error }
KVObject is Key/Value interface used by objects to be part of the Store.
type ScopeCfg ¶
type ScopeCfg struct {
Client ScopeClientCfg
}
ScopeCfg represents Datastore configuration.
func DefaultScope ¶
DefaultScope returns a default scope config for clients to use.
type ScopeClientCfg ¶
ScopeClientCfg represents Datastore Client-only mode configuration
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) DeleteObject ¶
DeleteObject deletes a kvObject from the on-disk DB and the in-memory cache. Unlike DeleteObjectAtomic, it doesn't check the optimistic lock of the passed kvObject.
func (*Store) DeleteObjectAtomic ¶
DeleteObjectAtomic performs atomic delete on a record.
func (*Store) GetObject ¶
GetObject gets data from the store and unmarshals to the specified object.
func (*Store) List ¶
List returns of a list of KVObjects belonging to the parent key. The caller must pass a KVObject of the same type as the objects that need to be listed.
func (*Store) PutObjectAtomic ¶
PutObjectAtomic provides an atomic add and update operation for a Record.