Skip to content

Commit

Permalink
fix(timer): don't rely on timer.at return value (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
flrgh committed Oct 6, 2023
1 parent 946fe09 commit a1ca416
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/doorbell/log/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ local function log_writer(premature)
flush(true)

else
assert(timer.at(0, "request-logger", log_writer, TIMER_OPTS))
timer.at(0, "request-logger", log_writer, TIMER_OPTS)
end
end

Expand Down
6 changes: 6 additions & 0 deletions lib/doorbell/util/timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ end
---@param name string
---@param fn function
---@param opts? doorbell.util.timer.opts
---@return true
function _M.every(period, name, fn, opts)
fn = wrapped(name, fn)

Expand All @@ -106,13 +107,16 @@ function _M.every(period, name, fn, opts)

opts = opts or EMPTY
assert(timer_at(0, run_every, time, name, period, fn, opts))

return true
end


---@param timeout number
---@param name string
---@param fn function
---@param opts? doorbell.util.timer.opts
---@return true
function _M.at(timeout, name, fn, opts)
fn = wrapped(name, fn)
opts = opts or EMPTY
Expand All @@ -125,6 +129,8 @@ function _M.at(timeout, name, fn, opts)
fn()
end))
end

return true
end

return _M

0 comments on commit a1ca416

Please sign in to comment.