Dynamic LB sync non-external backends only when necessary
This commit is contained in:
parent
10dcf0db15
commit
bcc3cfaa65
4 changed files with 91 additions and 6 deletions
|
|
@ -9,6 +9,14 @@ function _M.get_backends_data()
|
|||
return tcp_udp_configuration_data:get("backends")
|
||||
end
|
||||
|
||||
function _M.get_raw_backends_last_synced_at()
|
||||
local raw_backends_last_synced_at = tcp_udp_configuration_data:get("raw_backends_last_synced_at")
|
||||
if raw_backends_last_synced_at == nil then
|
||||
raw_backends_last_synced_at = 1
|
||||
end
|
||||
return raw_backends_last_synced_at
|
||||
end
|
||||
|
||||
function _M.call()
|
||||
local sock, err = ngx.req.socket(true)
|
||||
if not sock then
|
||||
|
|
@ -35,6 +43,17 @@ function _M.call()
|
|||
ngx.say("error: ", err_conf)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.update_time()
|
||||
local raw_backends_last_synced_at = ngx.time()
|
||||
success, err = tcp_udp_configuration_data:set("raw_backends_last_synced_at",
|
||||
raw_backends_last_synced_at)
|
||||
if not success then
|
||||
ngx.log(ngx.ERR, "dynamic-configuration: error updating when backends sync, " ..
|
||||
"new upstream peers waiting for force syncing: " .. tostring(err))
|
||||
ngx.status = ngx.HTTP_BAD_REQUEST
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return _M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue