fix lua lints
This commit is contained in:
parent
1387f7b7eb
commit
97d3a0ddab
3 changed files with 12 additions and 8 deletions
|
|
@ -78,15 +78,15 @@ end
|
|||
|
||||
function _M.balance(self)
|
||||
local peers = self.peers
|
||||
local endpoint, score = peers[1], -1
|
||||
local endpoint, ewma_score = peers[1], -1
|
||||
|
||||
if #peers > 1 then
|
||||
local k = (#peers < PICK_SET_SIZE) and #peers or PICK_SET_SIZE
|
||||
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
|
||||
|
||||
ngx.var.balancer_ewma_score = score
|
||||
ngx.var.balancer_ewma_score = ewma_score
|
||||
|
||||
-- TODO(elvinefendi) move this processing to _M.sync
|
||||
return endpoint.address .. ":" .. endpoint.port
|
||||
|
|
|
|||
|
|
@ -132,13 +132,16 @@ function _M.balance(self)
|
|||
end
|
||||
|
||||
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
|
||||
return upstream_from_cookie
|
||||
end
|
||||
|
||||
local new_upstream, key = pick_new_upstream(self)
|
||||
local new_upstream
|
||||
|
||||
new_upstream, key = pick_new_upstream(self)
|
||||
if not new_upstream then
|
||||
ngx.log(ngx.WARN, string.format("failed to get new upstream; using upstream %s", new_upstream))
|
||||
elseif should_set_cookie(self) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue