Documentation ¶
Index ¶
- Variables
- func Setup(storageDir string) error
- type Backend
- type Cache
- func (c *Cache) CheckIfAdded(key string, revision uint64) bool
- func (c *Cache) CheckIfExists(key string) bool
- func (c *Cache) CheckIfUpdated(key string, revision uint64) bool
- func (c *Cache) Get(key string) uint64
- func (c *Cache) RegisterDeleteFunc(prefix string, deleteFunc deleteFuncType)
- func (c *Cache) Remove(key string)
- func (c *Cache) RunController() error
- func (c *Cache) Set(key string, revision uint64)
- func (c *Cache) StopController()
- type Informer
Constants ¶
This section is empty.
Variables ¶
var ( // RegisteredInformers contains a list of store Informers configured using the package // it is useful for printing debug information related to store. RegisteredInformers map[string]*Informer = make(map[string]*Informer) // ControllerManager is a global controller manager for all the store Informers ControllerManager *controller.Manager = controller.NewManager() )
Functions ¶
Types ¶
type Backend ¶
type Backend interface { // GetName returns the name of the backend module. GetName() string // Close closes the database client and does not allow to do any more transactions. Close() error // Configured returns if the backend client has been configured or not. Configured() bool // Status returns the status of the initialized backend, it returns an error // if anything is wrong with the backend module. Status() (string, error) // Get returns the value of the key. Get(ctx context.Context, key string) (*types.Value, error) // Exists checks if the provided key exists or not Exists(ctx context.Context, key string) (bool, error) // KeyDoesNotExistError is the method to check if the error is due to non // existance of the key during the get operation. KeyDoesNotExistError(err error) bool // GetPrefix returns the first key which matches the prefix and its value GetPrefix(ctx context.Context, prefix string) (string, *types.Value, error) // Set sets value of key Set(ctx context.Context, key string, value []byte) error // Delete deletes a key Delete(ctx context.Context, key string) error // DeletePrefix deletes the first key which matches the prefix and its value. DeletePrefix(ctx context.Context, path string) error // CreateOnly atomically creates a key or fails if it already exists CreateOnly(ctx context.Context, key string, value []byte) (bool, error) // CreateIfExists creates a key with the value only if key condKey exists CreateIfExists(ctx context.Context, condKey, key string, value []byte) error // ListPrefixKeys list all the keys with the provided prefix. ListPrefixKeys(ctx context.Context, path string) ([]string, error) // ListPrefix returns a list of keys matching the prefix ListPrefix(ctx context.Context, prefix string) (types.KeyValuePairs, error) // ListPrefix returns a list of keys matching the prefix PrefixScanWithFunction(ctx context.Context, prefix string, f types.KVPairStructFunc) // Encodes a binary slice into a character set that the backend // supports Encode(in []byte) string // Decodes a key previously encoded back into the original binary slice Decode(in string) ([]byte, error) }
Backend is the interface which needs to be implemented by each client configured for the store.
var KVStore Backend
KVStore is the configured backend store for xene.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a map containing store keys corresponding to the last revision applied for the same object.
GlobalSharedCache is the global shared cache that can be used by any of the store controller.
func (*Cache) CheckIfAdded ¶
CheckIfAdded checks if the key and the revision provided have been added looking at the configured cache.
func (*Cache) CheckIfExists ¶
CheckIfExists checks if the provided key exists in the cache or not.
func (*Cache) CheckIfUpdated ¶
CheckIfUpdated checks if the key and the revision provided have been added or updated looking at the configured cache.
func (*Cache) RegisterDeleteFunc ¶
RegisterDeleteFunc registers a delete function for delete on the registered prefix.
func (*Cache) RunController ¶
RunController starts running the cache controller.
func (*Cache) StopController ¶
func (c *Cache) StopController()
StopController stops the running controller.
type Informer ¶
type Informer struct { AddFunc addFuncType UpdateFunc updateFuncType DeleteFunc deleteFuncType // Key is the prefix key to watch for. Key string Manager *controller.Manager // contains filtered or unexported fields }
Informer is a type corresponding to a store Informer. A store Informer can be used to run function based on changes to a store object.
func NewInformer ¶
func NewInformer( key string, addFunc func(*v1alpha1.KVPairStruct) error, delFunc func(string) error, updateFunc func(*v1alpha1.KVPairStruct, uint64) error) *Informer
NewInformer returns a new store controller to periodically run functions based on changes to the specifed key in the store.
func NewInformerWithSharedCache ¶
func NewInformerWithSharedCache( key string, addFunc func(*v1alpha1.KVPairStruct) error, delFunc func(string) error, updateFunc func(*v1alpha1.KVPairStruct, uint64) error) *Informer
NewInformerWithSharedCache returns a new store Informer to periodically run functions based on changes to the specifed key in the store. The Informer in this case is configured with the global shared store, which share its state with other Informer.
func (*Informer) DeleteFromCache ¶
DeleteFromCache deletes the entry from the store cache.