Skip to content

Commit

Permalink
code clean: start_sync_timer
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 12, 2024
1 parent 2090740 commit 8fbc8ae
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions kong/clustering/services/sync/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ local function do_sync(premature)
end


function _M:sync_once(delay)
local hdl, err = ngx.timer.at(delay or 0, do_sync)
local function start_sync_timer(timer_func, delay)
local hdl, err = timer_func(delay or 0, do_sync)

if not hdl then
return nil, err
Expand All @@ -330,14 +330,13 @@ function _M:sync_once(delay)
end


function _M:sync_every(delay)
local hdl, err = ngx.timer.every(delay, do_sync)
function _M:sync_once(delay)
return start_sync_timer(ngx.timer.at, delay or 0)
end

if not hdl then
return nil, err
end

return true
function _M:sync_every(delay)
return start_sync_timer(ngx.timer.every, delay)
end


Expand Down

0 comments on commit 8fbc8ae

Please sign in to comment.