|
|
@@ -2,8 +2,8 @@ package etcd
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
- "github.com/coreos/etcd/clientv3"
|
|
|
"git.wanbits.io/joe/kettle/utl"
|
|
|
+ "github.com/coreos/etcd/clientv3"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
@@ -47,11 +47,11 @@ func (self *EtcdClient) ClusterMembers() []*clientv3.Member {
|
|
|
return ret
|
|
|
}
|
|
|
|
|
|
-func (self *EtcdClient) Put(k, v string) error {
|
|
|
+func (self *EtcdClient) Put(k, v string, ops ...clientv3.OpOption) error {
|
|
|
//ctx, cancel := context.WithTimeout(context.Background(), self.timeout)
|
|
|
//defer cancel()
|
|
|
|
|
|
- _, err := self.c.Put(context.TODO(), k, v)
|
|
|
+ _, err := self.c.Put(context.TODO(), k, v, ops...)
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
@@ -75,16 +75,16 @@ func (self *EtcdClient) KeepAlive(leaseId clientv3.LeaseID) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (self *EtcdClient) KeepAliveOnce(leaseId clientv3.LeaseID)error {
|
|
|
+func (self *EtcdClient) KeepAliveOnce(leaseId clientv3.LeaseID) error {
|
|
|
_, err := self.c.KeepAliveOnce(context.TODO(), leaseId)
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-func (self *EtcdClient) Get(k string) ([]byte, error) {
|
|
|
+func (self *EtcdClient) Get(k string, ops ...clientv3.OpOption) ([]byte, error) {
|
|
|
//ctx, cancel := context.WithTimeout(context.Background(), self.timeout)
|
|
|
//defer cancel()
|
|
|
|
|
|
- resp, err := self.c.Get(context.TODO(), k)
|
|
|
+ resp, err := self.c.Get(context.TODO(), k, ops...)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
@@ -117,8 +117,8 @@ func (self *EtcdClient) Revoke(leaseId clientv3.LeaseID) error {
|
|
|
}
|
|
|
|
|
|
//// watch
|
|
|
-func (self *EtcdClient) Watch(k string) clientv3.WatchChan {
|
|
|
- return self.c.Watch(context.Background(), k)
|
|
|
+func (self *EtcdClient) Watch(k string, ops ...clientv3.OpOption) clientv3.WatchChan {
|
|
|
+ return self.c.Watch(context.Background(), k, ops...)
|
|
|
}
|
|
|
|
|
|
func (self *EtcdClient) WatchPrefix(prefix string) clientv3.WatchChan {
|
|
|
@@ -145,4 +145,4 @@ func (self *EtcdClient) Defrag(endpoint string) error {
|
|
|
|
|
|
_, err := self.c.Defragment(ctx, endpoint)
|
|
|
return err
|
|
|
-}
|
|
|
+}
|