1 Star 3 Fork 1

baiyangzhuhong / openresty-lua-timer

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
README.md 1.09 KB
Copy Edit Raw Blame History
baiyangzhuhong authored 2021-10-14 06:00 . initial commit

openresty-lua-timer

介绍

基于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

参与贡献

  1. Fork 本仓库
  2. 提交代码
  3. 新建 Pull Request
Lua
1
https://gitee.com/baiyangzhuhong/openresty-lua-timer.git
git@gitee.com:baiyangzhuhong/openresty-lua-timer.git
baiyangzhuhong
openresty-lua-timer
openresty-lua-timer
master

Search