update libkv import ,return DoRegister error,change zk register put to atomicPut

This commit is contained in:
wuguofu
2020-12-03 19:50:24 +08:00
parent a922ef3768
commit 142b3daeb5
11 changed files with 34 additions and 29 deletions
+3 -3
View File
@@ -10,9 +10,9 @@ import (
"sync"
"time"
"github.com/docker/libkv"
"github.com/docker/libkv/store"
"github.com/docker/libkv/store/consul"
"github.com/rpcxio/libkv"
"github.com/rpcxio/libkv/store"
"github.com/rpcxio/libkv/store/consul"
metrics "github.com/rcrowley/go-metrics"
"github.com/smallnest/rpcx/log"
)
+3 -3
View File
@@ -10,9 +10,9 @@ import (
"sync"
"time"
"github.com/docker/libkv"
"github.com/docker/libkv/store"
"github.com/docker/libkv/store/etcd"
"github.com/rpcxio/libkv"
"github.com/rpcxio/libkv/store"
"github.com/rpcxio/libkv/store/etcd"
metrics "github.com/rcrowley/go-metrics"
"github.com/smallnest/rpcx/log"
)
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"sync"
"time"
"github.com/docker/libkv"
"github.com/docker/libkv/store"
"github.com/rpcxio/libkv"
"github.com/rpcxio/libkv/store"
metrics "github.com/rcrowley/go-metrics"
etcd "github.com/smallnest/libkv-etcdv3-store"
"github.com/smallnest/rpcx/log"
+4 -4
View File
@@ -10,11 +10,11 @@ import (
"sync"
"time"
"github.com/docker/libkv"
"github.com/docker/libkv/store/zookeeper"
"github.com/rpcxio/libkv"
"github.com/rpcxio/libkv/store/zookeeper"
"github.com/docker/libkv/store"
metrics "github.com/rcrowley/go-metrics"
"github.com/rpcxio/libkv/store"
"github.com/smallnest/rpcx/log"
)
@@ -205,7 +205,7 @@ func (p *ZooKeeperRegisterPlugin) Register(name string, rcvr interface{}, metada
}
nodePath = fmt.Sprintf("%s/%s/%s", p.BasePath, name, p.ServiceAddress)
err = p.kv.Put(nodePath, []byte(metadata), &store.WriteOptions{TTL: p.UpdateInterval * 2})
_, _, err = p.kv.AtomicPut(nodePath, []byte(metadata), nil, &store.WriteOptions{TTL: p.UpdateInterval * 2})
if err != nil {
log.Errorf("cannot create zk path %s: %v", nodePath, err)
return err