Skip to content

Commit

Permalink
fix(healthcheck): replace checker callback timer with ngx.thread to l…
Browse files Browse the repository at this point in the history
…ower timer usage
  • Loading branch information
windmgc committed May 6, 2024
1 parent 264b5b5 commit 1670687
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1236,19 +1236,16 @@ local function checker_callback(self, health_mode)
if not list_to_check[1] then
self:log(DEBUG, "checking ", health_mode, " targets: nothing to do")
else
local timer = resty_timer({
interval = 0,
recurring = false,
immediate = false,
detached = true,
expire = function()
self:log(DEBUG, "checking ", health_mode, " targets: #", #list_to_check)
self:active_check_targets(list_to_check)
end,
})
if timer == nil then
self:log(ERR, "failed to create timer to check ", health_mode)
local thread = ngx.thread.spawn(function(mode, list)
self:log(DEBUG, "checking ", mode, " targets: #", #list)
self:active_check_targets(list)
end, health_mode, list_to_check)

if thread == nil then
self:log(ERR, "failed to create thread to check ", health_mode)
return
end
ngx.thread.wait(thread)
end
end

Expand Down

0 comments on commit 1670687

Please sign in to comment.