-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathclient.go
43 lines (36 loc) · 1.12 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* This file is part of easyKV.
* Based on code from confd. https://github.com/kelseyhightower/confd
* © 2013 Kelsey Hightower
* © 2016 The easyKV Authors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package easykv
import "context"
// WatchOptions represents options for watch operations
type WatchOptions struct {
WaitIndex uint64
Keys []string
}
// WatchOption configures the WatchPrefix operation
type WatchOption func(*WatchOptions)
// WithKeys reduces the scope of keys that can trigger updates to keys (not an exact match)
func WithKeys(keys []string) WatchOption {
return func(o *WatchOptions) {
o.Keys = keys
}
}
// WithWaitIndex sets the WaitIndex of the watcher
func WithWaitIndex(waitIndex uint64) WatchOption {
return func(o *WatchOptions) {
o.WaitIndex = waitIndex
}
}
// A ReadWatcher - can get values and watch a prefix for changes
type ReadWatcher interface {
GetValues(keys []string) (map[string]string, error)
WatchPrefix(ctx context.Context, prefix string, opts ...WatchOption) (uint64, error)
Close()
}