Enable lj-releng tool to lint lua code.
This commit is contained in:
parent
36f7dd2e0b
commit
bafbd4cccf
36 changed files with 213 additions and 93 deletions
|
|
@ -3,12 +3,14 @@ local resty_chash = require("resty.chash")
|
|||
local util = require("util")
|
||||
local ngx_log = ngx.log
|
||||
local ngx_ERR = ngx.ERR
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local _M = balancer_resty:new({ factory = resty_chash, name = "chash" })
|
||||
|
||||
function _M.new(self, backend)
|
||||
local nodes = util.get_nodes(backend.endpoints)
|
||||
local complex_val, err = util.parse_complex_value(backend["upstreamHashByConfig"]["upstream-hash-by"])
|
||||
local complex_val, err =
|
||||
util.parse_complex_value(backend["upstreamHashByConfig"]["upstream-hash-by"])
|
||||
if err ~= nil then
|
||||
ngx_log(ngx_ERR, "could not parse the value of the upstream-hash-by: ", err)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ local resty_chash = require("resty.chash")
|
|||
local util = require("util")
|
||||
local ngx_log = ngx.log
|
||||
local ngx_ERR = ngx.ERR
|
||||
local setmetatable = setmetatable
|
||||
local tostring = tostring
|
||||
local math = math
|
||||
local table = table
|
||||
local pairs = pairs
|
||||
|
||||
local _M = { name = "chashsubset" }
|
||||
|
||||
|
|
@ -46,7 +51,8 @@ end
|
|||
|
||||
function _M.new(self, backend)
|
||||
local subset_map, subsets = build_subset_map(backend)
|
||||
local complex_val, err = util.parse_complex_value(backend["upstreamHashByConfig"]["upstream-hash-by"])
|
||||
local complex_val, err =
|
||||
util.parse_complex_value(backend["upstreamHashByConfig"]["upstream-hash-by"])
|
||||
if err ~= nil then
|
||||
ngx_log(ngx_ERR, "could not parse the value of the upstream-hash-by: ", err)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ local resty_lock = require("resty.lock")
|
|||
local util = require("util")
|
||||
local split = require("util.split")
|
||||
|
||||
local ngx = ngx
|
||||
local math = math
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
local tostring = tostring
|
||||
local string = string
|
||||
local tonumber = tonumber
|
||||
local setmetatable = setmetatable
|
||||
local string_format = string.format
|
||||
local ngx_log = ngx.log
|
||||
local INFO = ngx.INFO
|
||||
|
|
@ -185,7 +193,8 @@ function _M.after_balance(_)
|
|||
end
|
||||
|
||||
function _M.sync(self, backend)
|
||||
local normalized_endpoints_added, normalized_endpoints_removed = util.diff_endpoints(self.peers, backend.endpoints)
|
||||
local normalized_endpoints_added, normalized_endpoints_removed =
|
||||
util.diff_endpoints(self.peers, backend.endpoints)
|
||||
|
||||
if #normalized_endpoints_added == 0 and #normalized_endpoints_removed == 0 then
|
||||
ngx.log(ngx.INFO, "endpoints did not change for backend " .. tostring(backend.name))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ local util = require("util")
|
|||
local string_format = string.format
|
||||
local ngx_log = ngx.log
|
||||
local INFO = ngx.INFO
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local _M = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ local balancer_resty = require("balancer.resty")
|
|||
local resty_roundrobin = require("resty.roundrobin")
|
||||
local util = require("util")
|
||||
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local _M = balancer_resty:new({ factory = resty_roundrobin, name = "round_robin" })
|
||||
|
||||
function _M.new(self, backend)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,13 @@ local ngx_balancer = require("ngx.balancer")
|
|||
local split = require("util.split")
|
||||
local same_site = require("util.same_site")
|
||||
|
||||
local ngx = ngx
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
local string = string
|
||||
local tonumber = tonumber
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local _M = balancer_resty:new()
|
||||
local DEFAULT_COOKIE_NAME = "route"
|
||||
|
||||
|
|
@ -64,7 +71,8 @@ function _M.set_cookie(self, value)
|
|||
}
|
||||
|
||||
if self.cookie_session_affinity.expires and self.cookie_session_affinity.expires ~= "" then
|
||||
cookie_data.expires = ngx.cookie_time(ngx.time() + tonumber(self.cookie_session_affinity.expires))
|
||||
cookie_data.expires = ngx.cookie_time(ngx.time() +
|
||||
tonumber(self.cookie_session_affinity.expires))
|
||||
end
|
||||
|
||||
if self.cookie_session_affinity.maxage and self.cookie_session_affinity.maxage ~= "" then
|
||||
|
|
@ -132,8 +140,8 @@ 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
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ local math_random = require("math").random
|
|||
local resty_chash = require("resty.chash")
|
||||
local util_get_nodes = require("util").get_nodes
|
||||
|
||||
local ngx = ngx
|
||||
local string = string
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local _M = balancer_sticky:new()
|
||||
|
||||
-- Consider the situation of N upstreams one of which is failing.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
local balancer_sticky = require("balancer.sticky")
|
||||
local util_get_nodes = require("util").get_nodes
|
||||
local util_nodemap = require("util.nodemap")
|
||||
local setmetatable = setmetatable
|
||||
|
||||
local _M = balancer_sticky:new()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue