Skip to content
Snippets Groups Projects
Commit fa7263b0 authored by panty's avatar panty Committed by GitHub
Browse files

Merge pull request #359 from hxmhlt/mod_zk_listen

Mod:cancel listener dir when zkpath end of providers/ & consumers/
parents 04bc1208 e89ceb85
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@ const (
DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"
APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"
PROVIDER_CATEGORY = "providers"
CONSUMER_CATEGORY = "consumers"
)
const (
......
......@@ -19,6 +19,7 @@ package zookeeper
import (
"path"
"strings"
"sync"
"time"
)
......@@ -30,6 +31,7 @@ import (
)
import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/remoting"
)
......@@ -256,10 +258,14 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
}(dubboPath, listener)
//listen sub path recursive
go func(zkPath string, listener remoting.DataListener) {
l.listenDirEvent(zkPath, listener)
logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath)
}(dubboPath, listener)
//if zkPath is end of "providers/ & consumers/" we do not listen children dir
if strings.LastIndex(zkPath, constant.PROVIDER_CATEGORY) == -1 &&
strings.LastIndex(zkPath, constant.CONSUMER_CATEGORY) == -1 {
go func(zkPath string, listener remoting.DataListener) {
l.listenDirEvent(zkPath, listener)
logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath)
}(dubboPath, listener)
}
}
select {
case zkEvent = <-childEventCh:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment