kvstore

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Local  = "local"
	Consul = "consul"
	Etcd   = "etcd"
)

Supported key-value store types.

Variables

View Source
var ConsulOpts = map[string]bool{
	// contains filtered or unexported fields
}

/ ConsulOpts is the set of supported options for Consul configuration.

View Source
var EtcdOpts = map[string]bool{
	// contains filtered or unexported fields
}

EtcdOpts is the set of supported options for Etcd configuration.

Functions

func GetLockPath

func GetLockPath(path string) string

GetLockPath returns the lock path representation of the given path.

func Setup added in v0.10.0

func Setup(selectedBackend string, opts map[string]string) error

Setup sets up the key-value store specified in kvStore and configures it with the options provided in kvStoreOpts.

func SetupDummy added in v0.10.0

func SetupDummy() error

SetupDummy sets up kvstore for tests

Types

type ConsulClient

type ConsulClient struct {
	*consulAPI.Client
}

func (*ConsulClient) DeleteTree

func (c *ConsulClient) DeleteTree(path string) error

func (*ConsulClient) GASNewL3n4AddrID

func (c *ConsulClient) GASNewL3n4AddrID(basePath string, baseID uint32, lAddrID *types.L3n4AddrID) error

func (*ConsulClient) GASNewSecLabelID

func (c *ConsulClient) GASNewSecLabelID(basePath string, baseID uint32, pI *policy.Identity) error

func (*ConsulClient) GetMaxID

func (c *ConsulClient) GetMaxID(key string, firstID uint32) (uint32, error)

GetMaxID returns the maximum possible free UUID stored in consul.

func (*ConsulClient) GetValue

func (c *ConsulClient) GetValue(k string) (json.RawMessage, error)

func (*ConsulClient) GetWatcher

func (c *ConsulClient) GetWatcher(key string, timeSleep time.Duration) <-chan []policy.NumericIdentity

GetWatcher watches for kvstore changes in the given key. Triggers the returned channel every time the key path is changed. FIXME This function is highly tightened to the maxFreeID, change name accordingly

func (*ConsulClient) InitializeFreeID

func (c *ConsulClient) InitializeFreeID(path string, firstID uint32) error

func (*ConsulClient) LockPath

func (c *ConsulClient) LockPath(path string) (KVLocker, error)

func (*ConsulClient) SetMaxID

func (c *ConsulClient) SetMaxID(key string, firstID, maxID uint32) error

func (*ConsulClient) SetValue

func (c *ConsulClient) SetValue(k string, v interface{}) error

func (*ConsulClient) Status

func (c *ConsulClient) Status() (string, error)

type EtcdClient

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

func (*EtcdClient) CheckMinVersion added in v0.10.0

func (e *EtcdClient) CheckMinVersion(timeout time.Duration) error

CheckMinVersion checks the minimal version running on etcd cluster. If the minimal version running doesn't meet cilium minimal requirements, returns an error.

func (*EtcdClient) DeleteTree

func (e *EtcdClient) DeleteTree(path string) error

func (*EtcdClient) GASNewL3n4AddrID

func (e *EtcdClient) GASNewL3n4AddrID(basePath string, baseID uint32, lAddrID *types.L3n4AddrID) error

GASNewL3n4AddrID gets the next available ServiceID and sets it in lAddrID. After assigning the ServiceID to lAddrID it sets the ServiceID + 1 in common.LastFreeServiceIDKeyPath path.

func (*EtcdClient) GASNewSecLabelID

func (e *EtcdClient) GASNewSecLabelID(basePath string, baseID uint32, pI *policy.Identity) error

GASNewSecLabelID gets the next available LabelID and sets it in id. After assigning the LabelID to id it sets the LabelID + 1 in common.LastFreeLabelIDKeyPath path.

func (*EtcdClient) GetMaxID

func (e *EtcdClient) GetMaxID(key string, firstID uint32) (uint32, error)

func (*EtcdClient) GetValue

func (e *EtcdClient) GetValue(k string) (json.RawMessage, error)

func (*EtcdClient) GetWatcher

func (e *EtcdClient) GetWatcher(key string, timeSleep time.Duration) <-chan []policy.NumericIdentity

GetWatcher watches for kvstore changes in the given key. Triggers the returned channel every time the key path is changed. FIXME This function is highly tightened to the maxFreeID, change name accordingly

func (*EtcdClient) InitializeFreeID

func (e *EtcdClient) InitializeFreeID(path string, firstID uint32) error

func (*EtcdClient) LockPath

func (e *EtcdClient) LockPath(path string) (KVLocker, error)

func (*EtcdClient) SetMaxID

func (e *EtcdClient) SetMaxID(key string, firstID, maxID uint32) error

func (*EtcdClient) SetValue

func (e *EtcdClient) SetValue(k string, v interface{}) error

func (*EtcdClient) Status

func (e *EtcdClient) Status() (string, error)

type EtcdLocker

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

func (*EtcdLocker) Unlock

func (e *EtcdLocker) Unlock() error

type KVClient

type KVClient interface {
	LockPath(path string) (KVLocker, error)
	GetValue(k string) (json.RawMessage, error)
	SetValue(k string, v interface{}) error
	InitializeFreeID(path string, firstID uint32) error
	GetMaxID(key string, firstID uint32) (uint32, error)
	SetMaxID(key string, firstID, maxID uint32) error

	GASNewSecLabelID(baseKeyPath string, baseID uint32, secCtxLabels *policy.Identity) error
	GASNewL3n4AddrID(basePath string, baseID uint32, lAddrID *types.L3n4AddrID) error

	DeleteTree(path string) error

	GetWatcher(key string, timeSleep time.Duration) <-chan []policy.NumericIdentity

	Status() (string, error)
}
var Client KVClient

Client is the instance of the key-value as configured

func NewLocalClient

func NewLocalClient() KVClient

type KVLocker

type KVLocker interface {
	Unlock() error
}

type LocalClient

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

func (*LocalClient) DeleteTree

func (l *LocalClient) DeleteTree(path string) error

func (*LocalClient) GASNewL3n4AddrID

func (l *LocalClient) GASNewL3n4AddrID(basePath string, baseID uint32, lAddrID *types.L3n4AddrID) error

func (*LocalClient) GASNewSecLabelID

func (l *LocalClient) GASNewSecLabelID(basePath string, baseID uint32, pI *policy.Identity) error

func (*LocalClient) GetMaxID

func (l *LocalClient) GetMaxID(key string, firstID uint32) (uint32, error)

func (*LocalClient) GetValue

func (l *LocalClient) GetValue(k string) (json.RawMessage, error)

func (*LocalClient) GetWatcher

func (l *LocalClient) GetWatcher(key string, timeSleep time.Duration) <-chan []policy.NumericIdentity

func (*LocalClient) InitializeFreeID

func (l *LocalClient) InitializeFreeID(path string, firstID uint32) error

func (*LocalClient) LockPath

func (l *LocalClient) LockPath(path string) (KVLocker, error)

func (*LocalClient) SetMaxID

func (l *LocalClient) SetMaxID(key string, firstID, maxID uint32) error

func (*LocalClient) SetValue

func (l *LocalClient) SetValue(k string, v interface{}) error

func (*LocalClient) Status

func (l *LocalClient) Status() (string, error)

type LocalLocker

type LocalLocker struct {
}

func (*LocalLocker) Unlock

func (l *LocalLocker) Unlock() error

Jump to

Keyboard shortcuts

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