Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // List returns a list of keys under the given prefix. Returned keys will // include the prefix. List(ctx context.Context, prefix string) ([]string, error) // Get a specific key. Will use a codec to deserialise key to appropriate type. // If the key does not exist, Get will return nil and no error. Get(ctx context.Context, key string) (interface{}, error) // Delete a specific key. Deletions are best-effort and no error will // be returned if the key does not exist. Delete(ctx context.Context, key string) error // CAS stands for Compare-And-Swap. Will call provided callback f with the // current value of the key and allow callback to return a different value. // Will then attempt to atomically swap the current value for the new value. // If that doesn't succeed will try again - callback will be called again // with new value etc. Guarantees that only a single concurrent CAS // succeeds. Callback can return nil to indicate it is happy with existing // value. CAS(ctx context.Context, key string, f func(in interface{}) (out interface{}, retry bool, err error)) error // WatchKey calls f whenever the value stored under key changes. WatchKey(ctx context.Context, key string, f func(interface{}) bool) // WatchPrefix calls f whenever any value stored under prefix changes. WatchPrefix(ctx context.Context, prefix string, f func(string, interface{}) bool) }
Client is a high-level client for key-value stores (such as Etcd and Consul) that exposes operations such as CAS and Watch which take callbacks. It also deals with serialisation by using a Codec and having a instance of the the desired type passed in to methods ala json.Unmarshal.
func PrefixClient ¶
PrefixClient takes a KVClient and forces a prefix on all its operations.
Click to show internal directories.
Click to hide internal directories.