Skip to content

Commit

Permalink
feature: support ignore down servers in extract_servers_from_upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
starsz committed Nov 25, 2019
1 parent 52ccf94 commit 43b28e0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/resty/checkups/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ function _M.extract_servers_from_upstream(skey, cls)
end

local ups_backup = cls.upstream_only_backup
local ups_skip_down = cls.upstream_skip_down
local srvs_getter = ngx_upstream.get_primary_peers
if ups_backup then
srvs_getter = ngx_upstream.get_backup_peers
Expand All @@ -294,6 +295,10 @@ function _M.extract_servers_from_upstream(skey, cls)
end

for _, srv in ipairs(srvs) do
if ups_skip_down and srv.down then
goto continue
end

local host, port = extract_srv_host_port(srv.name)
if not host then
log(ERR, "invalid server name: ", srv.name)
Expand All @@ -308,6 +313,8 @@ function _M.extract_servers_from_upstream(skey, cls)
max_fails = srv.max_fails,
fail_timeout = srv.fail_timeout,
})

::continue::
end
end

Expand Down

0 comments on commit 43b28e0

Please sign in to comment.