Open dhjack opened 4 years ago
这个不应该,可以稳定复现么?或者你跟踪一下代码,看看rpcx从etcd读取出来的数据是一个还是两个?
加了点打印:node会重复一次 2020/09/13 21:13:01 show kvs:[0xc00029e0c0 0xc00029e0f0] 2020/09/13 21:13:01 show nodes:[0xc0001f5a10 0xc0001f5a40] 2020/09/13 21:13:01 add services:&{L3JwY3hfdGVzdEBBcml0aA== /rpcx_test Arith Arith active } 2020/09/13 21:13:01 add services:&{QXJpdGhAdGNwQGxvY2FsaG9zdDo4ODg4 Arith tcp@localhost:8888 active } 2020/09/13 21:13:01 show nodes:[0xc00029e4b0] 2020/09/13 21:13:01 add services:&{QXJpdGhAdGNwQGxvY2FsaG9zdDo4ODg4 Arith tcp@localhost:8888 active }
代码: diff --git a/etcdv3_service.go b/etcdv3_service.go index 5e43453..da05970 100644 --- a/etcdv3_service.go +++ b/etcdv3_service.go @@ -37,6 +37,7 @@ func (r EtcdV3Registry) fetchServices() []Service { return services }
log.Printf("show kvs:%v", kvs) for _, value := range kvs {
nodes, err := r.kv.List(value.Key)
@@ -45,6 +46,7 @@ func (r EtcdV3Registry) fetchServices() []Service { continue }
log.Printf("show nodes:%v", nodes) for _, n := range nodes { key := string(n.Key[:]) i := strings.LastIndex(key, "/") @@ -71,6 +73,7 @@ func (r EtcdV3Registry) fetchServices() []Service { id := base64.StdEncoding.EncodeToString([]byte(serviceName + "@" + serviceAddr)) service := &Service{ID: id, Name: serviceName, Address: serviceAddr, Metadata: string(n.Value[:]), State: state, Group: group} services = append(services, service)
log.Printf("add services:%v", service) }
}
+1 for this issue.
确实有2个一样的
+1 for this issue.
e嗯嗯,待我验证下
+1 for this issue.
$ ./etcdctl get / --prefix
/rpcx_test rpcx_path /rpcx_test/Arith Arith /rpcx_test/Arith/tcp@localhost:8888 state=active&tps=