update pending2ReadyScript to adapt to alibaba Cloud #12

This commit is contained in:
finley
2024-02-12 13:01:37 +08:00
parent 8cabcf8c96
commit 461d5a1ab5
3 changed files with 19 additions and 4 deletions

15
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run Example",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/example"
}
]
}

View File

@@ -218,16 +218,16 @@ func (q *DelayQueue) SendDelayMsg(payload string, duration time.Duration, opts .
const pending2ReadyScript = ` const pending2ReadyScript = `
local msgs = redis.call('ZRangeByScore', KEYS[1], '0', ARGV[1]) -- get ready msg local msgs = redis.call('ZRangeByScore', KEYS[1], '0', ARGV[1]) -- get ready msg
if (#msgs == 0) then return end if (#msgs == 0) then return end
local args2 = {'LPush', KEYS[2]} -- push into ready local args2 = {} -- keys to push into ready
for _,v in ipairs(msgs) do for _,v in ipairs(msgs) do
table.insert(args2, v) table.insert(args2, v)
if (#args2 == 4000) then if (#args2 == 4000) then
redis.call(unpack(args2)) redis.call('LPush', KEYS[2], unpack(args2))
args2 = {'LPush', KEYS[2]} args2 = {}
end end
end end
if (#args2 > 2) then if (#args2 > 2) then
redis.call(unpack(args2)) redis.call('LPush', KEYS[2], unpack(args2))
end end
redis.call('ZRemRangeByScore', KEYS[1], '0', ARGV[1]) -- remove msgs from pending redis.call('ZRemRangeByScore', KEYS[1], '0', ARGV[1]) -- remove msgs from pending
` `