docker: github.com/docker/docker/vendor/github.com/docker/libnetwork/datastore Index | Files

package datastore

import "github.com/docker/docker/vendor/github.com/docker/libnetwork/datastore"

Index

Package Files

cache.go datastore.go mock_store.go

Constants

const (
    // LocalScope indicates to store the KV object in local datastore such as boltdb
    LocalScope = "local"
    // GlobalScope indicates to store the KV object in global datastore such as consul/etcd/zookeeper
    GlobalScope = "global"
    // SwarmScope is not indicating a datastore location. It is defined here
    // along with the other two scopes just for consistency.
    SwarmScope = "swarm"
)
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

var (
    // ErrNotImplemented exported
    ErrNotImplemented = errors.New("Functionality not implemented")
)

func DefaultScopes Uses

func DefaultScopes(dataDir string) map[string]*ScopeCfg

DefaultScopes returns a map of default scopes and its config for clients to use.

func Key Uses

func Key(key ...string) string

Key provides convenient method to create a Key

func ParseKey Uses

func ParseKey(key string) ([]string, error)

ParseKey provides convenient method to unpack the key to complement the Key function

type DataStore Uses

type DataStore interface {
    // GetObject gets data from datastore and unmarshals to the specified object
    GetObject(key string, o KVObject) error
    // PutObject adds a new Record based on an object into the datastore
    PutObject(kvObject KVObject) error
    // PutObjectAtomic provides an atomic add and update operation for a Record
    PutObjectAtomic(kvObject KVObject) error
    // DeleteObject deletes a record
    DeleteObject(kvObject KVObject) error
    // DeleteObjectAtomic performs an atomic delete operation
    DeleteObjectAtomic(kvObject KVObject) error
    // DeleteTree deletes a record
    DeleteTree(kvObject KVObject) error
    // Watchable returns whether the store is watchable or not
    Watchable() bool
    // Watch for changes on a KVObject
    Watch(kvObject KVObject, stopCh <-chan struct{}) (<-chan KVObject, error)
    // RestartWatch retriggers stopped Watches
    RestartWatch()
    // Active returns if the store is active
    Active() bool
    // 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
    List(string, KVObject) ([]KVObject, error)
    // Map returns a Map of KVObjects
    Map(key string, kvObject KVObject) (map[string]KVObject, error)
    // Scope returns the scope of the store
    Scope() string
    // KVStore returns access to the KV Store
    KVStore() store.Store
    // Close closes the data store
    Close()
}

DataStore exported

func NewDataStore Uses

func NewDataStore(scope string, cfg *ScopeCfg) (DataStore, error)

NewDataStore creates a new instance of LibKV data store

func NewDataStoreFromConfig Uses

func NewDataStoreFromConfig(dsc discoverapi.DatastoreConfigData) (DataStore, error)

NewDataStoreFromConfig creates a new instance of LibKV data store starting from the datastore config data

type KVConstructor Uses

type KVConstructor interface {
    // 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
}

KVConstructor interface defines methods which can construct a KVObject from another.

type KVObject Uses

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)
    // 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
    // DataScope indicates the storage scope of the KV object
    DataScope() string
    // Skip provides a way for a KV Object to avoid persisting it in the KV Store
    Skip() bool
}

KVObject is Key/Value interface used by objects to be part of the DataStore

type MockData Uses

type MockData struct {
    Data  []byte
    Index uint64
}

MockData exported

type MockStore Uses

type MockStore struct {
    // contains filtered or unexported fields
}

MockStore exported

func NewMockStore Uses

func NewMockStore() *MockStore

NewMockStore creates a Map backed Datastore that is useful for mocking

func (*MockStore) AtomicDelete Uses

func (s *MockStore) AtomicDelete(key string, previous *store.KVPair) (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 Uses

func (s *MockStore) AtomicPut(key string, newValue []byte, previous *store.KVPair, options *store.WriteOptions) (bool, *store.KVPair, 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) Close Uses

func (s *MockStore) Close()

Close closes the client connection

func (*MockStore) Delete Uses

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

Delete a value at "key"

func (*MockStore) DeleteTree Uses

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

DeleteTree deletes a range of values at "directory"

func (*MockStore) Exists Uses

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

Exists checks that the key exists inside the store

func (*MockStore) Get Uses

func (s *MockStore) Get(key string) (*store.KVPair, error)

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

func (*MockStore) List Uses

func (s *MockStore) List(prefix string) ([]*store.KVPair, error)

List gets a range of values at "directory"

func (*MockStore) NewLock Uses

func (s *MockStore) NewLock(key string, options *store.LockOptions) (store.Locker, error)

NewLock exposed

func (*MockStore) Put Uses

func (s *MockStore) Put(key string, value []byte, options *store.WriteOptions) error

Put a value at "key"

func (*MockStore) Watch Uses

func (s *MockStore) Watch(key string, stopCh <-chan struct{}) (<-chan *store.KVPair, error)

Watch a single key for modifications

func (*MockStore) WatchTree Uses

func (s *MockStore) WatchTree(prefix string, stopCh <-chan struct{}) (<-chan []*store.KVPair, error)

WatchTree triggers a watch on a range of values at "directory"

type ScopeCfg Uses

type ScopeCfg struct {
    Client ScopeClientCfg
}

ScopeCfg represents Datastore configuration.

func (*ScopeCfg) IsValid Uses

func (cfg *ScopeCfg) IsValid() bool

IsValid checks if the scope config has valid configuration.

type ScopeClientCfg Uses

type ScopeClientCfg struct {
    Provider string
    Address  string
    Config   *store.Config
}

ScopeClientCfg represents Datastore Client-only mode configuration

Package datastore imports 11 packages (graph). Updated 2018-09-01. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).