Fixed review findings.
This commit is contained in:
parent
880b3dc5f1
commit
f1839ddb42
4 changed files with 13 additions and 59 deletions
|
|
@ -4,13 +4,13 @@
|
|||
-- be rebalanced.
|
||||
--
|
||||
local balancer_sticky = require("balancer.sticky")
|
||||
local util = require("util")
|
||||
local util_get_nodes = require("util").get_nodes
|
||||
local util_nodemap = require("util.nodemap")
|
||||
|
||||
local _M = balancer_sticky:new()
|
||||
|
||||
function _M.new(self, backend)
|
||||
local nodes = util.get_nodes(backend.endpoints)
|
||||
local nodes = util_get_nodes(backend.endpoints)
|
||||
local hash_salt = backend["name"]
|
||||
|
||||
local o = {
|
||||
|
|
@ -26,29 +26,6 @@ function _M.new(self, backend)
|
|||
return o
|
||||
end
|
||||
|
||||
function _M.get_routing_key(self)
|
||||
local cookie_value = self:get_cookie()
|
||||
|
||||
if cookie_value then
|
||||
-- format <timestamp>.<workder-pid>.<routing-key>
|
||||
local routing_key = string.match(cookie_value, '[^\\.]+$')
|
||||
|
||||
if routing_key == nil then
|
||||
local err = string.format("Failed to extract routing key from cookie '%s'!", cookie_value)
|
||||
return nil, err
|
||||
end
|
||||
|
||||
return routing_key, nil
|
||||
end
|
||||
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
function _M.set_routing_key(self, key)
|
||||
local value = string.format("%s.%s.%s", ngx.now(), ngx.worker.pid(), key)
|
||||
self:set_cookie(value);
|
||||
end
|
||||
|
||||
function _M.pick_new_upstream(self, failed_upstreams)
|
||||
return self.instance:random_except(failed_upstreams)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue