This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/main by this push:
new 8b041402f Fixes #2428, zk registry support customize 'rootPath' (#2437)
8b041402f is described below
commit 8b041402f7d7cebb82effc0f6213f3f19f17c9ed
Author: huangjikun <[email protected]>
AuthorDate: Thu Oct 12 10:31:36 2023 +0800
Fixes #2428, zk registry support customize 'rootPath' (#2437)
---
registry/zookeeper/service_discovery.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/registry/zookeeper/service_discovery.go
b/registry/zookeeper/service_discovery.go
index 5a5d7be0c..915f10b2b 100644
--- a/registry/zookeeper/service_discovery.go
+++ b/registry/zookeeper/service_discovery.go
@@ -64,9 +64,14 @@ type zookeeperServiceDiscovery struct {
// newZookeeperServiceDiscovery the constructor of newZookeeperServiceDiscovery
func newZookeeperServiceDiscovery(url *common.URL) (registry.ServiceDiscovery,
error) {
+ group := url.GetParam(constant.RegistryGroupKey, rootPath)
+ if !strings.HasPrefix(group, constant.PathSeparator) {
+ group = constant.PathSeparator + group
+ }
+
zksd := &zookeeperServiceDiscovery{
url: url,
- rootPath: rootPath,
+ rootPath: group,
instanceListenerMap: make(map[string]*gxset.HashSet),
}
if err := zookeeper.ValidateZookeeperClient(zksd, url.Location); err !=
nil {
@@ -74,7 +79,7 @@ func newZookeeperServiceDiscovery(url *common.URL)
(registry.ServiceDiscovery, e
}
zksd.WaitGroup().Add(1) // zk client start successful, then wg +1
go zookeeper.HandleClientRestart(zksd)
- zksd.csd = curator_discovery.NewServiceDiscovery(zksd.client, rootPath)
+ zksd.csd = curator_discovery.NewServiceDiscovery(zksd.client, group)
return zksd, nil
}