Merge pull request #3341 from Shopify/canary_upstream
Add canary annotation and alternative backends for traffic shaping
This commit is contained in:
commit
17cad51e47
18 changed files with 859 additions and 23 deletions
|
|
@ -6,7 +6,10 @@ local _M = balancer_resty:new({ factory = resty_chash, name = "chash" })
|
|||
|
||||
function _M.new(self, backend)
|
||||
local nodes = util.get_nodes(backend.endpoints)
|
||||
local o = { instance = self.factory:new(nodes), hash_by = backend["upstream-hash-by"] }
|
||||
local o = {
|
||||
instance = self.factory:new(nodes),
|
||||
hash_by = backend["upstream-hash-by"],
|
||||
}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ function _M.after_balance(_)
|
|||
end
|
||||
|
||||
function _M.sync(self, backend)
|
||||
self.traffic_shaping_policy = backend.trafficShapingPolicy
|
||||
self.alternative_backends = backend.alternativeBackends
|
||||
|
||||
local changed = not util.deep_compare(self.peers, backend.endpoints)
|
||||
if not changed then
|
||||
return
|
||||
|
|
@ -115,7 +118,9 @@ function _M.sync(self, backend)
|
|||
end
|
||||
|
||||
function _M.new(self, backend)
|
||||
local o = { peers = backend.endpoints }
|
||||
local o = {
|
||||
peers = backend.endpoints,
|
||||
}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ function _M.new(self, o)
|
|||
end
|
||||
|
||||
function _M.sync(self, backend)
|
||||
self.traffic_shaping_policy = backend.trafficShapingPolicy
|
||||
self.alternative_backends = backend.alternativeBackends
|
||||
|
||||
local nodes = util.get_nodes(backend.endpoints)
|
||||
local changed = not util.deep_compare(self.instance.nodes, nodes)
|
||||
if not changed then
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ local _M = balancer_resty:new({ factory = resty_roundrobin, name = "round_robin"
|
|||
|
||||
function _M.new(self, backend)
|
||||
local nodes = util.get_nodes(backend.endpoints)
|
||||
local o = { instance = self.factory:new(nodes) }
|
||||
local o = {
|
||||
instance = self.factory:new(nodes),
|
||||
}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue