Skip to content
Snippets Groups Projects
Commit f43d5e76 authored by aliiohs's avatar aliiohs
Browse files

change select time.After to wheel.After

parent 197f248f
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package zookeeper package zookeeper
import ( import (
gxtime "github.com/dubbogo/gost/time"
"path" "path"
"sync" "sync"
"time" "time"
...@@ -33,6 +34,10 @@ import ( ...@@ -33,6 +34,10 @@ import (
"github.com/apache/dubbo-go/remoting" "github.com/apache/dubbo-go/remoting"
) )
var (
wheel = gxtime.NewWheel(gxtime.TimeSecondDuration(3), 12) // wheel longest span is 2 minute
)
type ZkEventListener struct { type ZkEventListener struct {
client *ZookeeperClient client *ZookeeperClient
pathMapLock sync.Mutex pathMapLock sync.Mutex
...@@ -188,7 +193,7 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi ...@@ -188,7 +193,7 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
} }
l.client.RegisterEvent(zkPath, &event) l.client.RegisterEvent(zkPath, &event)
select { select {
case <-time.After(timeSecondDuration(failTimes * ConnDelay)): case <-wheel.After(timeSecondDuration(failTimes * ConnDelay)):
l.client.UnregisterEvent(zkPath, &event) l.client.UnregisterEvent(zkPath, &event)
continue continue
case <-l.client.Done(): case <-l.client.Done():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment