Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBackendNotSupported is thrown when the backend k/v store is not supported by libkv ErrBackendNotSupported = errors.New("Backend storage not supported yet, please choose one of") // ErrCallNotSupported is thrown when a method is not implemented/supported by the current backend ErrCallNotSupported = errors.New("The current call is not supported with this backend") // ErrNotReachable is thrown when the API cannot be reached for issuing common store operations ErrNotReachable = errors.New("Api not reachable") // ErrCannotLock is thrown when there is an error acquiring a lock on a key ErrCannotLock = errors.New("Error acquiring the lock") // ErrKeyModified is thrown during an atomic operation if the index does not match the one in the store ErrKeyModified = errors.New("Unable to complete atomic operation, key modified") // ErrKeyNotFound is thrown when the key is not found in the store during a Get operation ErrKeyNotFound = errors.New("Key not found in store") // ErrPreviousNotSpecified is thrown when the previous value is not specified for an atomic operation ErrPreviousNotSpecified = errors.New("Previous K/V pair should be provided for the Atomic operation") // ErrKeyExists is thrown when the previous value exists in the case of an AtomicPut ErrKeyExists = errors.New("Previous K/V pair exists, cannnot complete Atomic operation") )
Functions ¶
func CreateEndpoints ¶
CreateEndpoints creates a list of endpoints given the right scheme
func Register ¶
func Register(name string, f Initializer)
Register a new store, the Intializer is a function used to initialize store
Types ¶
type Action ¶
type Action int
Action is the event type
const ( // ERROR event action, this will be set when geting error from backend(etcd, zk...) ERROR Action = iota - 1 // GET event action, useless GET // SET event action, same with update, it's useless SET // UPDATE event action, return when data changed in backend, include set, create, update, compareAndSwap UPDATE // DELETE event action, return when some key was delete or expired or compareAndDelete DELETE // INIT event action, this is only retured when calling watch() and only the first correct event. INIT )
type Event ¶
Event represents a event get from watch, Action is 'delete' or 'update' Data is the latest key-value-data of the watched key
type Initializer ¶
Initializer is initialization function which can create real store, used when Register()
type Store ¶
type Store interface { // Get a value given its key Get(key string) (*KVPair, error) // Get the content of a given prefix by recursive GetTree(key string) ([]*KVPair, error) // Set a value for the given key Put(key string, value []byte) error // Delete a key Delete(key string, recursive bool) error // Verify if a Key exists in the store Exists(key string) (bool, error) // Watch for changes on a key Watch(key string, ctx context.Context, recursive bool, index uint64) (<-chan *Event, error) // WatchTree watches for changes on child nodes under // a given directory WatchTree(directory string, ctx context.Context, index uint64) (<-chan *Event, error) // List all the nodes in a directory List(dir string) ([]string, error) // Close the store connection Close() }
Store represents the backend K/V storage Each store should support every call listed here. Or it couldn't be implemented as a K/V backend for libkv
Click to show internal directories.
Click to hide internal directories.