membphis commented on a change in pull request #1281: feature: Support for 
using Eureka as a service discovery center
URL: https://github.com/apache/incubator-apisix/pull/1281#discussion_r404483950
 
 

 ##########
 File path: apisix/balancer.lua
 ##########
 @@ -48,24 +50,50 @@ local _M = {
 
 
 local function fetch_health_nodes(upstream, checker)
+    local nodes = upstream.nodes
     if not checker then
-        return upstream.nodes
+        if core.table.isarray(nodes) then
+            local new_nodes = core.table.new(0, #nodes)
+            for _, node in ipairs(nodes) do
+                -- TODO filter with metadata
+                new_nodes[core.table.concat({node.host, ":", node.port})] = 
node.weight
+            end
+            return new_nodes
+        end
+
+        return nodes
     end
 
     local host = upstream.checks and upstream.checks.host
-    local up_nodes = core.table.new(0, core.table.nkeys(upstream.nodes))
+    local up_nodes
+    if core.table.isarray(nodes) then
 
 Review comment:
   We can convert the hash object of `node` into an array object by default.
   
   So that we can use it very easily.
   
   
https://github.com/apache/incubator-apisix/blob/master/apisix/balancer.lua#L323

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to