Fetch the repository succeeded.
基于openresty ngx_lua开发的一款应用于定时作业的定时器框架,支持创建和取消定时器。
框架基础代码从开源项目lua-resty-timer(https://github.com/Kong/lua-resty-timer)
而来,但对框架存在的内存泄漏问题进行了修复,并添加了一些方便管理的接口,及一些代码机制的调整。
下载源码, 使用luarocks编译安装
-- create timer
local resty_timer = require("resty.timer")
local interval = 5 -- seconds
local health_mode = "healthy"
local CHECK_JITTER = 0.1
local function callback ()
end
local timer_uuid, err = resty_timer({
interval = interval,
recurring = true,
immediate = true,
detached = true,
expire = callback,
cancel = nil,
shm_name = self.shm_name,
key_name = self.PERIODIC_LOCK .. health_mode,
sub_interval = math.min(interval, 0.5),
jitter = CHECK_JITTER,
}, self.name, health_mode)
if not timer_uuid then
-- log
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。