groupmq-plus 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lua/dead-letter.lua +3 -43
- package/package.json +1 -1
package/dist/lua/dead-letter.lua
CHANGED
|
@@ -7,9 +7,6 @@ local readyKey = ns .. ":ready"
|
|
|
7
7
|
|
|
8
8
|
local jobKey = ns .. ":job:" .. jobId
|
|
9
9
|
|
|
10
|
-
-- [FLOW SUPPORT: Get parentId before any cleanup]
|
|
11
|
-
local parentId = redis.call("HGET", jobKey, "parentId")
|
|
12
|
-
|
|
13
10
|
-- Remove job from group
|
|
14
11
|
redis.call("ZREM", gZ, jobId)
|
|
15
12
|
|
|
@@ -46,46 +43,9 @@ end
|
|
|
46
43
|
-- Optionally store in dead letter queue (uncomment if needed)
|
|
47
44
|
-- redis.call("LPUSH", ns .. ":dead", jobId)
|
|
48
45
|
|
|
49
|
-
-- [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-- 1. Store error result in flow:results hash
|
|
53
|
-
local flowResultsKey = ns .. ":flow:results:" .. parentId
|
|
54
|
-
-- [NEW] 核心变更:统一死信的存储格式
|
|
55
|
-
local flowEntry = cjson.encode({
|
|
56
|
-
status = "failed",
|
|
57
|
-
data = '{"error":"dead-lettered", "reason":"max attempts exceeded"}'
|
|
58
|
-
})
|
|
59
|
-
redis.call("HSET", flowResultsKey, jobId, flowEntry)
|
|
60
|
-
|
|
61
|
-
-- 2. Decrement remaining counter
|
|
62
|
-
local remaining = redis.call("HINCRBY", parentKey, "flowRemaining", -1)
|
|
63
|
-
|
|
64
|
-
-- 3. If all children done, move parent to waiting
|
|
65
|
-
if remaining <= 0 then
|
|
66
|
-
local parentStatus = redis.call("HGET", parentKey, "status")
|
|
67
|
-
if parentStatus == "waiting-children" then
|
|
68
|
-
redis.call("HSET", parentKey, "status", "waiting")
|
|
69
|
-
|
|
70
|
-
local parentGroupId = redis.call("HGET", parentKey, "groupId")
|
|
71
|
-
local parentScore = tonumber(redis.call("HGET", parentKey, "score"))
|
|
72
|
-
if not parentScore then
|
|
73
|
-
parentScore = tonumber(redis.call("TIME")[1]) * 1000
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
local pGZ = ns .. ":g:" .. parentGroupId
|
|
77
|
-
redis.call("ZADD", pGZ, parentScore, parentId)
|
|
78
|
-
redis.call("SADD", ns .. ":groups", parentGroupId)
|
|
79
|
-
|
|
80
|
-
-- Add to ready if head
|
|
81
|
-
local pHead = redis.call("ZRANGE", pGZ, 0, 0, "WITHSCORES")
|
|
82
|
-
if pHead and #pHead >= 2 then
|
|
83
|
-
local pHeadScore = tonumber(pHead[2])
|
|
84
|
-
redis.call("ZADD", readyKey, pHeadScore, parentGroupId)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
46
|
+
-- [DELETED: Flow logic removed to avoid double-decrementing flowRemaining]
|
|
47
|
+
-- The flow update is handled by record-job-result.lua which is called
|
|
48
|
+
-- immediately before dead-letter.lua in the worker's deadLetterJob method.
|
|
89
49
|
|
|
90
50
|
return 1
|
|
91
51
|
|