Firstsawyou commented on a change in pull request #3512:
URL: https://github.com/apache/apisix/pull/3512#discussion_r571548530
##########
File path: apisix/plugins/traffic-split.lua
##########
@@ -258,18 +258,21 @@ end
local function new_rr_obj(weighted_upstreams)
local server_list = {}
for i, upstream_obj in ipairs(weighted_upstreams) do
- if not upstream_obj.upstream then
+ if not upstream_obj.upstream and not upstream_obj.upstream_id then
-- If the `upstream` object has only the `weight` value, it means
-- that the `upstream` weight value on the default `route` has
been reached.
- -- Need to set an identifier to mark the empty upstream.
- upstream_obj.upstream = "empty_upstream"
+ -- Mark empty upstream services in the plugin, but with weight.
+ upstream_obj.upstream = "plugin#upstream#is#empty"
+ server_list[upstream_obj.upstream] = upstream_obj.weight
Review comment:
I don't think the key types of server_list need to be unified, because
the keys of server_list can accept different types. If unified, it will bring
additional data type conversion overhead.
----------------------------------------------------------------
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]