AsperforMias commented on code in PR #1126:
URL: 
https://github.com/apache/incubator-seata-go/pull/1126#discussion_r3485961432


##########
pkg/discovery/etcd3.go:
##########
@@ -218,41 +194,20 @@ func getClusterAndAddress(key []byte) (string, string, 
int, error) {
        return cluster, ip, port, nil
 }
 
-func ifHaveSameServiceInstances(list []*ServiceInstance, value 
*ServiceInstance) bool {
-       for _, v := range list {
-               if v.Addr == value.Addr && v.Port == value.Port {
-                       return true
-               }
-       }
-       return false
-}
-
-func removeValueFromList(list []*ServiceInstance, ip string, port int) 
[]*ServiceInstance {
-       for k, v := range list {
-               if v.Addr == ip && v.Port == port {
-                       result := list[:k]
-                       if k < len(list)-1 {
-                               result = append(result, list[k+1:]...)
-                       }
-                       return result
-               }
-       }
-
-       return list
-}
-
 func (s *EtcdRegistryService) Lookup(key string) ([]*ServiceInstance, error) {
-       s.rwLock.RLock()
-       defer s.rwLock.RUnlock()
        cluster := s.vgroupMapping[key]
        if cluster == "" {
                return nil, fmt.Errorf("cluster doesnt exit")
        }
 
-       list := s.grouplist[cluster]
-       return list, nil
+       return s.store.Snapshot(cluster), nil
 }
 
 func (s *EtcdRegistryService) Close() {

Review Comment:
   这里 Close 只停了 watch goroutine,没有关闭 etcd client。EtcdRegistryService 持有的是自己创建的 
client,Close 时是不是也应该调用 s.client.Close()?如果 registry 重新初始化或测试里反复创建/关闭时,etcd 
client 的连接和后台 goroutine 可能会泄漏



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to