commit
cc22aed52a
3 changed files with 12 additions and 8 deletions
|
@ -78,15 +78,15 @@ end
|
||||||
|
|
||||||
function _M.balance(self)
|
function _M.balance(self)
|
||||||
local peers = self.peers
|
local peers = self.peers
|
||||||
local endpoint, score = peers[1], -1
|
local endpoint, ewma_score = peers[1], -1
|
||||||
|
|
||||||
if #peers > 1 then
|
if #peers > 1 then
|
||||||
local k = (#peers < PICK_SET_SIZE) and #peers or PICK_SET_SIZE
|
local k = (#peers < PICK_SET_SIZE) and #peers or PICK_SET_SIZE
|
||||||
local peer_copy = util.deepcopy(peers)
|
local peer_copy = util.deepcopy(peers)
|
||||||
endpoint, score = pick_and_score(self, peer_copy, k)
|
endpoint, ewma_score = pick_and_score(self, peer_copy, k)
|
||||||
end
|
end
|
||||||
|
|
||||||
ngx.var.balancer_ewma_score = score
|
ngx.var.balancer_ewma_score = ewma_score
|
||||||
|
|
||||||
-- TODO(elvinefendi) move this processing to _M.sync
|
-- TODO(elvinefendi) move this processing to _M.sync
|
||||||
return endpoint.address .. ":" .. endpoint.port
|
return endpoint.address .. ":" .. endpoint.port
|
||||||
|
|
|
@ -132,13 +132,16 @@ function _M.balance(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
local last_failure = self.get_last_failure()
|
local last_failure = self.get_last_failure()
|
||||||
local should_pick_new_upstream = last_failure ~= nil and self.cookie_session_affinity.change_on_failure or upstream_from_cookie == nil
|
local should_pick_new_upstream = last_failure ~= nil and self.cookie_session_affinity.change_on_failure or
|
||||||
|
upstream_from_cookie == nil
|
||||||
|
|
||||||
if not should_pick_new_upstream then
|
if not should_pick_new_upstream then
|
||||||
return upstream_from_cookie
|
return upstream_from_cookie
|
||||||
end
|
end
|
||||||
|
|
||||||
local new_upstream, key = pick_new_upstream(self)
|
local new_upstream
|
||||||
|
|
||||||
|
new_upstream, key = pick_new_upstream(self)
|
||||||
if not new_upstream then
|
if not new_upstream then
|
||||||
ngx.log(ngx.WARN, string.format("failed to get new upstream; using upstream %s", new_upstream))
|
ngx.log(ngx.WARN, string.format("failed to get new upstream; using upstream %s", new_upstream))
|
||||||
elseif should_set_cookie(self) then
|
elseif should_set_cookie(self) then
|
||||||
|
|
|
@ -59,13 +59,14 @@ local function handle_servers()
|
||||||
local err_buf = {}
|
local err_buf = {}
|
||||||
for _, server in ipairs(servers) do
|
for _, server in ipairs(servers) do
|
||||||
if server.hostname and server.sslCert.pemCertKey then
|
if server.hostname and server.sslCert.pemCertKey then
|
||||||
local success, err, forcible = certificate_data:set(server.hostname, server.sslCert.pemCertKey)
|
local success, set_err, forcible = certificate_data:set(server.hostname, server.sslCert.pemCertKey)
|
||||||
if not success then
|
if not success then
|
||||||
local err_msg = string.format("error setting certificate for %s: %s\n", server.hostname, tostring(err))
|
local err_msg = string.format("error setting certificate for %s: %s\n", server.hostname, tostring(set_err))
|
||||||
table.insert(err_buf, err_msg)
|
table.insert(err_buf, err_msg)
|
||||||
end
|
end
|
||||||
if forcible then
|
if forcible then
|
||||||
local msg = string.format("certificate_data dictionary is full, LRU entry has been removed to store %s", server.hostname)
|
local msg = string.format("certificate_data dictionary is full, LRU entry has been removed to store %s",
|
||||||
|
server.hostname)
|
||||||
ngx.log(ngx.WARN, msg)
|
ngx.log(ngx.WARN, msg)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue