queue.lua
_product = {}
_product['default'] = { redo_num = 3, redo_time = 300, do_num = 10,}
_product['ami-weixin'] = { redo_num = 3, redo_time = 10, do_num = 10,}
--
local function dolist(v) return _queue_do:index(v)end
for k,v in pairs(_product) do v['productId'] = k threads[k] = ngx.thread.spawn(dolist, v)end
for k,v in pairs(threads) do ok,waits[k] = ngx.thread.wait(v)endfunction queue_do:index(con)
local num = con.do_num
ngx.ctx._redis = nil ngx.ctx._redis = redis:new(nil,ngx.ctx._config._sc_conf_redis)
local key = _string.key_head..con['productId']
local restable = {} for i=1,num do local res,err = ngx.ctx._redis:lpop(key)
if not _fun:value_true_false(res) then break end
res = json.decode(res) restable[i] = res end
---把取出来的任务,使用thread全部http请求 ---ngx.thread.spawn(http请求) ---
end