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/05/13 01:55:18 UTC

[GitHub] [apisix] tokers commented on a change in pull request #4208: feat: support passing different host headers in multiple nodes

tokers commented on a change in pull request #4208:
URL: https://github.com/apache/apisix/pull/4208#discussion_r631511727



##########
File path: apisix/init.lua
##########
@@ -800,6 +801,14 @@ function _M.stream_preread_phase()
         core.log.error("failed to set upstream: ", err)
         return ngx_exit(1)
     end
+
+    local server, err = load_balancer.pick_server(matched_route, api_ctx)
+    if not server then
+        core.log.error("failed to pick server: ", err)
+        return ngx_exit(1)

Review comment:
       What does `ngx.exit(1)` mean?

##########
File path: apisix/balancer.lua
##########
@@ -98,16 +98,29 @@ local function create_server_picker(upstream, checker)
     end
 
     if picker then
+        local nodes = upstream.nodes
+        local addr_to_domain = {}
+        for _, node in ipairs(nodes) do
+            if node.domain then
+                local addr = node.host .. ":" .. node.port
+                addr_to_domain[addr] = node.domain
+            end
+        end
+
         local up_nodes = fetch_health_nodes(upstream, checker)
 
         if #up_nodes._priority_index > 1 then
             core.log.info("upstream nodes: ", core.json.delay_encode(up_nodes))
-            return priority_balancer.new(up_nodes, upstream, picker)
+            local server_picker = priority_balancer.new(up_nodes, upstream, picker)

Review comment:
       Why not add a new parameter `addr_to_domain` for `priority_balancer.new`.




-- 
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:
users@infra.apache.org