-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
52 lines (39 loc) · 1.04 KB
/
doc.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
44
45
46
47
48
49
50
51
52
/*
Package etcdutil helps implementation of the common specification to
take etcd connection parameters.
To read parameters from YAML (or JSON):
import (
"github.com/cybozu-go/etcdutil"
"sigs.k8s.io/yaml"
)
func main() {
cfg := etcdutil.NewConfig("/key-prefix/")
err := yaml.Unmarshal(data, cfg)
if err != nil {
panic(err)
}
etcd, err := etcdutil.NewClient(cfg)
if err != nil {
panic(err)
}
defer etcd.Close()
// use etcd; it is a etcd *clientv3.Client object.
}
To read parameters from command-line flags:
import (
"flag"
"github.com/cybozu-go/etcdutil"
)
func main() {
cfg := etcdutil.NewConfig("/key-prefix/")
cfg.AddFlags(flag.CommandLine)
flag.Parse()
etcd, err := etcdutil.NewClient(cfg)
if err != nil {
panic(err)
}
defer etcd.Close()
// use etcd; it is a etcd *clientv3.Client object.
}
*/
package etcdutil