@@ -11,11 +11,6 @@ import (
1111 "github.com/coreos/etcd/client"
1212)
1313
14- var (
15- retryCycles = 2
16- retrySleep = 200 * time .Millisecond
17- )
18-
1914// Getter describes the Get behavior of an Etcd client.
2015//
2116// Usually you will want to use go-etcd/etcd.Client to satisfy this.
@@ -53,22 +48,22 @@ type GetterSetter interface {
5348// - retrySleep (time.Duration): How long to sleep between retries
5449//
5550// Returns:
56- // This puts a simpleEtcdClient into context (implements Getter, Setter, etc.)
51+ // This puts a SimpleEtcdClient into context (implements Getter, Setter, etc.)
5752func CreateSimpleClient (c cookoo.Context , p * cookoo.Params ) (interface {}, cookoo.Interrupt ) {
5853 r , e := CreateClient (c , p )
5954 if e != nil {
6055 return c , e
6156 }
6257
63- return & simpleEtcdClient {
58+ return & SimpleEtcdClient {
6459 realClient : r .(client.Client ),
6560 }, nil
6661}
6762
68- // Provides a simple wrapper around the old API.
63+ // NewSimpleClient Provides a simple wrapper around the old API.
6964//
7065// DO NOT USE for new code. Instead, use NewClient().
71- func NewSimpleClient (hosts []string ) (* simpleEtcdClient , error ) {
66+ func NewSimpleClient (hosts []string ) (* SimpleEtcdClient , error ) {
7267 cfg := client.Config {
7368 Endpoints : hosts ,
7469 }
@@ -78,29 +73,32 @@ func NewSimpleClient(hosts []string) (*simpleEtcdClient, error) {
7873 return nil , err
7974 }
8075
81- return & simpleEtcdClient {
76+ return & SimpleEtcdClient {
8277 realClient : r ,
8378 }, nil
8479}
8580
86- // simpleEtcdClient provides an interface compatible with the old Etcd client.
87- type simpleEtcdClient struct {
81+ // SimpleEtcdClient provides an interface compatible with the old Etcd client.
82+ type SimpleEtcdClient struct {
8883 realClient client.Client
8984}
9085
91- func (c * simpleEtcdClient ) Get (key string , sort bool , rec bool ) (* client.Response , error ) {
86+ // Get client.Response
87+ func (c * SimpleEtcdClient ) Get (key string , sort bool , rec bool ) (* client.Response , error ) {
9288 k := client .NewKeysAPI (c .realClient )
9389 return k .Get (dctx (), key , & client.GetOptions {Sort : sort , Recursive : rec })
9490}
9591
96- func (c * simpleEtcdClient ) Set (key , val string , ttl uint64 ) (* client.Response , error ) {
92+ // Set client.Response
93+ func (c * SimpleEtcdClient ) Set (key , val string , ttl uint64 ) (* client.Response , error ) {
9794 k := client .NewKeysAPI (c .realClient )
9895 // We're banking on people not using really uge ttls. In the code base, the
9996 // highest is only a few hundred.
10097 return k .Set (dctx (), key , val , & client.SetOptions {TTL : time .Duration (ttl ) * time .Second })
10198}
10299
103- func (c * simpleEtcdClient ) CreateDir (name string , ttl uint64 ) (* client.Response , error ) {
100+ // CreateDir by name
101+ func (c * SimpleEtcdClient ) CreateDir (name string , ttl uint64 ) (* client.Response , error ) {
104102 k := client .NewKeysAPI (c .realClient )
105103 return k .Set (dctx (), name , "" , & client.SetOptions {TTL : time .Duration (ttl ) * time .Second , Dir : true })
106104}
0 commit comments