Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix log flooding #14

Merged
merged 7 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/resty/timerng/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ local _M = {
-- 1s
SCALING_RECORD_INTERVAL = 1,

-- 60s
SACALING_INFO_LOG_INTERVAL = 60,
-- 10m
SCALING_INFO_LOG_INTERVAL = 600,
}

-- We don't need a high accuracy.
Expand Down
18 changes: 4 additions & 14 deletions lib/resty/timerng/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ local wheel_group = require("resty.timerng.wheel.group")
local constants = require("resty.timerng.constants")
local thread_group = require("resty.timerng.thread.group")

local ngx_log = ngx.log
local ngx_DEBUG = ngx.DEBUG

local utils_float_compare = utils.float_compare

local table_insert = table.insert
Expand Down Expand Up @@ -387,11 +384,8 @@ function _M:named_at(name, delay, callback, ...)
assert(type(delay) == "number", "expected `delay to be a number")
assert(delay >= 0, "expected `delay` to be greater than or equal to 0")

if delay >= self.max_expire
or (delay ~= 0 and delay < self.opt.resolution)
if delay >= self.max_expire or (delay ~= 0 and delay < self.opt.resolution)
then
ngx_log(ngx_DEBUG, "[timer-ng] fallback to ngx.timer.at [delay = ",
delay, "]")
return ngx_timer_at(delay, callback, ...)
end

Expand All @@ -410,12 +404,8 @@ function _M:named_every(name, interval, callback, ...)
assert(type(interval) == "number", "expected `interval to be a number")
assert(interval > 0, "expected `interval` to be greater than or equal to 0")

if interval >= self.max_expire
or interval < self.opt.resolution then
ngx_log(ngx_DEBUG,
"[timer-ng] fallback to ngx.timer.every [interval = ",
interval,
"]")
if interval >= self.max_expire or interval < self.opt.resolution
then
return ngx_timer_every(interval, callback, ...)
end

Expand Down Expand Up @@ -604,4 +594,4 @@ function _M:_debug_expected_alive_worker_thread_count()
end


return _M
return _M
2 changes: 1 addition & 1 deletion lib/resty/timerng/thread/super.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local CONSTANTS_SCALING_RECORD_INTERVAL =
local CONSTANTS_TOLERANCE_OF_GRACEFUL_SHUTDOWN =
constants.TOLERANCE_OF_GRACEFUL_SHUTDOWN
local CONSTANTS_SCALING_LOG_INTERVAL =
constants.SACALING_INFO_LOG_INTERVAL
constants.SCALING_INFO_LOG_INTERVAL

local setmetatable = setmetatable

Expand Down