| 1 |
// Package backend provides the K/V store interface for crypt backends. |
| 2 |
package backend |
| 3 |
|
| 4 |
// Response represents a response from a backend store. |
| 5 |
type Response struct { |
| 6 |
Value []byte |
| 7 |
Error error |
| 8 |
} |
| 9 |
|
| 10 |
// KVPair holds both a key and value when reading a list. |
| 11 |
type KVPair struct { |
| 12 |
Key string |
| 13 |
Value []byte |
| 14 |
} |
| 15 |
|
| 16 |
type KVPairs []*KVPair |
| 17 |
|
| 18 |
// A Store is a K/V store backend that retrieves and sets, and monitors |
| 19 |
// data in a K/V store. |
| 20 |
type Store interface { |
| 21 |
// Get retrieves a value from a K/V store for the provided key. |
| 22 |
Get(key string) ([]byte, error) |
| 23 |
|
| 24 |
// List retrieves all keys and values under a provided key. |
| 25 |
List(key string) (KVPairs, error) |
| 26 |
|
| 27 |
// Set sets the provided key to value. |
| 28 |
Set(key string, value []byte) error |
| 29 |
|
| 30 |
// Watch monitors a K/V store for changes to key. |
| 31 |
Watch(key string, stop chan bool) <-chan *Response |
| 32 |
} |