fix bug with lua sticky session implementation and refactor balancer

This commit is contained in:
Elvin Efendi 2018-05-09 11:26:04 -04:00
parent 94198fce83
commit 7ac4e1db30
8 changed files with 194 additions and 299 deletions

View file

@ -117,7 +117,8 @@ local function pick_and_score(peers, k)
return peers[lowest_score_index]
end
function _M.balance(peers)
function _M.balance(backend)
local peers = backend.endpoints
if #peers == 1 then
return peers[1]
end
@ -138,4 +139,10 @@ function _M.after_balance()
get_or_update_ewma(upstream, rtt, true)
end
function _M.sync(_)
-- TODO: Reset state of EWMA per backend
ngx.shared.balancer_ewma:flush_all()
ngx.shared.balancer_ewma_last_touched_at:flush_all()
end
return _M