This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch fix/issue1166
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git

commit f1377247ddb0a8dd56cc23be0036bb8cd488afc4
Author: AlexStocks <[email protected]>
AuthorDate: Sat May 29 20:02:05 2021 +0800

    fix issue 1166: treat all zk child path url as new child
---
 remoting/zookeeper/listener.go | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index 216fb8c..f63eb65 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -160,10 +160,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, 
children []string, li
                newNode string
        )
        for _, n := range newChildren {
-               if contains(children, n) {
-                       continue
-               }
-
                newNode = path.Join(zkPath, n)
                logger.Infof("add zkNode{%s}", newNode)
                content, _, connErr := l.client.Conn.Get(newNode)
@@ -323,12 +319,24 @@ func (l *ZkEventListener) listenDirEvent(conf 
*common.URL, zkPath string, listen
                        }
                }
                // Periodically update provider information
-               ticker := time.NewTicker(ttl)
+               tickerTTL := ttl
+               if tickerTTL < 30e9 {
+                       tickerTTL = 30e9
+               }
+               ticker := time.NewTicker(tickerTTL)
        WATCH:
                for {
                        select {
                        case <-ticker.C:
                                l.handleZkNodeEvent(zkPath, children, listener)
+                               if tickerTTL < ttl {
+                                       tickerTTL *= 2
+                                       if tickerTTL > ttl {
+                                               tickerTTL = ttl
+                                       }
+                                       ticker.Stop()
+                                       ticker = time.NewTicker(tickerTTL)
+                               }
                        case zkEvent = <-childEventCh:
                                logger.Warnf("get a zookeeper 
childEventCh{type:%s, server:%s, path:%s, state:%d-%s, err:%s}",
                                        zkEvent.Type.String(), zkEvent.Server, 
zkEvent.Path, zkEvent.State, gxzookeeper.StateToString(zkEvent.State), 
zkEvent.Err)

Reply via email to