Documentation ¶
Index ¶
- func IsNotFound(err error) bool
- type ETCD
- func (e *ETCD) Close() error
- func (e *ETCD) Delete(ctx context.Context, key string) error
- func (e *ETCD) Get(ctx context.Context, key string) (string, error)
- func (e *ETCD) List(ctx context.Context, root string) (map[string]string, error)
- func (e *ETCD) Lock(ctx context.Context, key string) (func(), error)
- func (e *ETCD) Put(ctx context.Context, key, value string) error
- type Lister
- type Locker
- type NotFoundError
- type Reader
- type TestKV
- func (t *TestKV) Copy() *TestKV
- func (t *TestKV) Delete(ctx context.Context, key string) error
- func (t *TestKV) Get(ctx context.Context, key string) (string, error)
- func (t *TestKV) List(ctx context.Context, root string) (map[string]string, error)
- func (t *TestKV) Lock(ctx context.Context, key string) (func(), error)
- func (t *TestKV) Put(ctx context.Context, key, value string) error
- type Vault
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound returns true if the error returned is for a key that was not found.
Types ¶
type ETCD ¶
type ETCD struct {
// contains filtered or unexported fields
}
ETCD is a wrapper around the ETCD client that implements the backend.KV interface.
func NewETCDClient ¶
NewETCDClient returns a new ETCD v3 client. Returns an error in case the connection to all endpoints fails.
func (*ETCD) Delete ¶
Delete deletes a key from ETCD. Returns NotFoundError in case the key does not exist.
func (*ETCD) Get ¶
Get retrieves values from ETCD. Returns NotFoundError in case the key does not exist.
func (*ETCD) Lock ¶
Lock creates a new distributes lock on a key. Any future locks on the same key block until the lock is released. The lock is released if the context is cancelled.
When no longer needed, the lock must be unlocked by calling the returned unlock function.
Note: if the context is cancelled due to a timeout, this will still wait to acquire the lock. The lock will timeout automatically by a value set on the ETCD server (default 60 seconds).
type Lister ¶
type Lister interface { // List lists keys directly under a root key. List(ctx context.Context, root string) (map[string]string, error) }
The Lister interface is implemented by backends that can list keys under a key.
type Locker ¶
type Locker interface { // Locker creates a distributed lock on a key. Lock(ctx context.Context, key string) (func(), error) }
Locker locks resources, preventing multiple clients modifying the same resource in the backend.
type NotFoundError ¶
type NotFoundError struct { // Key is the key that was not found. Key string }
NotFoundError indicates that a key was not found.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Error returns the error string for a not found error.
type Reader ¶
type Reader interface { // Get gets a value. In case the key does not exist, returns NotFoundError // if the key was not found. Get(ctx context.Context, key string) (string, error) }
Reader reads values from a backend.
type TestKV ¶
TestKV keeps data in memory. It should only be used for unit tests.
func NewTestKV ¶
func NewTestKV() *TestKV
NewTestKV creates a new in key-value backend for tests. Snapshots are loaded to set the initial state.
func (*TestKV) Copy ¶
Copy returns a copy of the TestKV, including its data. This is meant for unit tests, where a single instance of the TestKV is created, and copies of it are mutated.
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
Vault implemnts KV by storing values in Vault as generic secrets. Only the generic secret backend is supported.
func NewVaultClient ¶
NewVaultClient creates a new Vault client and connects to the Vault server The environment variable VAULT_TOKEN is read automatically to authenticate the client. Returns an error if the address is not in a valid url.
func (*Vault) Delete ¶
Delete deletes a generic secret from Vault. Returns NotFoundError if the secret does not exist.
Since Vault doesn't return if the secret was actually deleted a check is done first to read the key.
type Writer ¶
type Writer interface { // Put inserts a value under a key. In case the value already exists it is // overwritten. The key is case-insensitive. Put(ctx context.Context, key, value string) error // Delete deletes a key. In case the key does not exist, returns NotFoundError // if the key was not found. Delete(ctx context.Context, key string) error }
The Writer interface is implemented by a backend that can be written to.