You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/09/22 00:53:42 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #5083: fix(nacos): distinguish services that has same name but in different groups or namespaces

spacewander commented on a change in pull request #5083:
URL: https://github.com/apache/apisix/pull/5083#discussion_r713514538



##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]

Review comment:
       Better to add an indent here

##########
File path: apisix/discovery/nacos.lua
##########
@@ -235,12 +237,12 @@ local function iter_and_add_service(services, values)
 
         local namespace_id
         if up.discovery_args then
-            namespace_id = up.discovery_args.namespace_id
+            namespace_id = up.discovery_args.namespace_id or default_namespace_id

Review comment:
       Look like the default value is not necessary here? We already use one in fetch_full_registry

##########
File path: apisix/discovery/nacos.lua
##########
@@ -307,11 +311,21 @@ local function fetch_full_registry(premature)
             return
         end
 
+        if not up_apps[namespace_id] then
+            up_apps[namespace_id] = {}
+        end
+
+        if not up_apps[namespace_id][group_name] then
+            up_apps[namespace_id][group_name] = {}
+        end
+
         for _, host in ipairs(data.hosts) do
-            local nodes = up_apps[service_info.service_name]
+            local nodes = up_apps[namespace_id]
+            [group_name][service_info.service_name]
             if not nodes then
                 nodes = {}
-                up_apps[service_info.service_name] = nodes
+                up_apps[namespace_id]
+                [group_name][service_info.service_name] = nodes

Review comment:
       Ditto




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org