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 fe5afaae1 fix(registry/nacos): Fixed the bug that NACOS service 
discovery could not obtain all service names, and added the ability to filter 
interface-level service IDs (#2715)
fe5afaae1 is described below

commit fe5afaae1b307e6a8465e39bb3c17aa120318a6a
Author: Allen442 <[email protected]>
AuthorDate: Fri Jul 26 10:21:52 2024 +0800

    fix(registry/nacos): Fixed the bug that NACOS service discovery could not 
obtain all service names, and added the ability to filter interface-level 
service IDs (#2715)
---
 registry/nacos/service_discovery.go | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/registry/nacos/service_discovery.go 
b/registry/nacos/service_discovery.go
index 7fa41b621..59a4ea027 100644
--- a/registry/nacos/service_discovery.go
+++ b/registry/nacos/service_discovery.go
@@ -19,6 +19,7 @@ package nacos
 
 import (
        "fmt"
+       "regexp"
        "sync"
 )
 
@@ -122,20 +123,32 @@ func (n *nacosServiceDiscovery) GetDefaultPageSize() int {
 
 // GetServices will return the all services
 func (n *nacosServiceDiscovery) GetServices() *gxset.HashSet {
-       services, err := 
n.namingClient.Client().GetAllServicesInfo(vo.GetAllServiceInfoParam{
-               GroupName: n.group,
-       })
-
        res := gxset.NewSet()
-       if err != nil {
-               logger.Errorf("Could not query the services: %v", err)
-               return res
-       }
 
-       for _, e := range services.Doms {
-               res.Add(e)
+       //Filter out interface-level service DataIds
+       const pattern = `^providers:[\w\.]+(?::[\w\.]*:|::[\w\.]*)?$`
+       re := regexp.MustCompile(pattern)
+       for pageNo := uint32(1); ; pageNo++ {
+               services, err := 
n.namingClient.Client().GetAllServicesInfo(vo.GetAllServiceInfoParam{
+                       PageSize:  uint32(n.GetDefaultPageSize()),
+                       PageNo:    pageNo,
+                       GroupName: n.group,
+               })
+
+               if err != nil {
+                       logger.Errorf("Could not query the services: %v", err)
+                       return res
+               }
+               for _, e := range services.Doms {
+                       if !re.MatchString(e) {
+                               res.Add(e)
+                       }
+               }
+
+               if int(services.Count) < n.GetDefaultPageSize() {
+                       return res
+               }
        }
-       return res
 }
 
 // GetInstances will return the instances of serviceName and the group

Reply via email to