bullmq 1.77.1 → 1.77.2
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/cjs/commands/addJob-9.lua +3 -2
- package/dist/cjs/commands/cleanJobsInSet-2.lua +14 -4
- package/dist/cjs/commands/includes/trimEvents.lua +1 -1
- package/dist/cjs/commands/moveStalledJobsToWait-8.lua +3 -2
- package/dist/esm/commands/addJob-9.lua +3 -2
- package/dist/esm/commands/cleanJobsInSet-2.lua +14 -4
- package/dist/esm/commands/includes/trimEvents.lua +1 -1
- package/dist/esm/commands/moveStalledJobsToWait-8.lua +3 -2
- package/package.json +1 -1
@@ -77,6 +77,9 @@ local jobCounter = rcall("INCR", KEYS[4])
|
|
77
77
|
-- Includes
|
78
78
|
--- @include "includes/updateParentDepsIfNeeded"
|
79
79
|
|
80
|
+
-- Trim events before emiting them to avoid trimming events emitted in this script
|
81
|
+
trimEvents(KEYS[3], KEYS[8])
|
82
|
+
|
80
83
|
local parentDependenciesKey = args[7]
|
81
84
|
if args[2] == "" then
|
82
85
|
jobId = jobCounter
|
@@ -174,6 +177,4 @@ if parentDependenciesKey ~= nil then
|
|
174
177
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
175
178
|
end
|
176
179
|
|
177
|
-
trimEvents(KEYS[3], KEYS[8])
|
178
|
-
|
179
180
|
return jobId .. "" -- convert to string
|
@@ -42,8 +42,10 @@ local jobs = rcall(command, KEYS[1], rangeStart, rangeEnd)
|
|
42
42
|
local deleted = {}
|
43
43
|
local deletedCount = 0
|
44
44
|
local jobTS
|
45
|
+
local deletionMarker = ''
|
46
|
+
local jobIdsLen = #jobs
|
45
47
|
if ARGV[4] == "active" then
|
46
|
-
for
|
48
|
+
for i, job in ipairs(jobs) do
|
47
49
|
if limit > 0 and deletedCount >= limit then
|
48
50
|
break
|
49
51
|
end
|
@@ -52,7 +54,9 @@ if ARGV[4] == "active" then
|
|
52
54
|
if (rcall("EXISTS", jobKey .. ":lock") == 0) then
|
53
55
|
jobTS = rcall("HGET", jobKey, "timestamp")
|
54
56
|
if (not jobTS or jobTS < ARGV[2]) then
|
55
|
-
|
57
|
+
-- replace the entry with a deletion marker; the actual deletion will
|
58
|
+
-- occur at the end of the script
|
59
|
+
rcall("LSET", KEYS[1], rangeEnd - jobIdsLen + i, deletionMarker)
|
56
60
|
removeJob(job, true, ARGV[1])
|
57
61
|
deletedCount = deletedCount + 1
|
58
62
|
table.insert(deleted, job)
|
@@ -60,7 +64,7 @@ if ARGV[4] == "active" then
|
|
60
64
|
end
|
61
65
|
end
|
62
66
|
else
|
63
|
-
for
|
67
|
+
for i, job in ipairs(jobs) do
|
64
68
|
if limit > 0 and deletedCount >= limit then
|
65
69
|
break
|
66
70
|
end
|
@@ -69,7 +73,9 @@ else
|
|
69
73
|
jobTS = rcall("HGET", jobKey, "timestamp")
|
70
74
|
if (not jobTS or jobTS < ARGV[2]) then
|
71
75
|
if isList then
|
72
|
-
|
76
|
+
-- replace the entry with a deletion marker; the actual deletion will
|
77
|
+
-- occur at the end of the script
|
78
|
+
rcall("LSET", KEYS[1], rangeEnd - jobIdsLen + i, deletionMarker)
|
73
79
|
end
|
74
80
|
removeJob(job, true, ARGV[1])
|
75
81
|
deletedCount = deletedCount + 1
|
@@ -86,6 +92,10 @@ else
|
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
95
|
+
if isList then
|
96
|
+
rcall("LREM", KEYS[1], 0, deletionMarker)
|
97
|
+
end
|
98
|
+
|
89
99
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", deletedCount)
|
90
100
|
|
91
101
|
return deleted
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
local function trimEvents(metaKey, eventStreamKey)
|
6
6
|
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
|
7
|
-
if
|
7
|
+
if maxEvents ~= false then
|
8
8
|
rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)
|
9
9
|
else
|
10
10
|
rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)
|
@@ -32,6 +32,9 @@ if rcall("EXISTS", KEYS[5]) == 1 then return {{}, {}} end
|
|
32
32
|
|
33
33
|
rcall("SET", KEYS[5], ARGV[3], "PX", ARGV[4])
|
34
34
|
|
35
|
+
-- Trim events before emiting them to avoid trimming events emitted in this script
|
36
|
+
trimEvents(KEYS[6], KEYS[8])
|
37
|
+
|
35
38
|
-- Move all stalled jobs to wait
|
36
39
|
local stalling = rcall('SMEMBERS', KEYS[1])
|
37
40
|
local stalled = {}
|
@@ -97,6 +100,4 @@ if (#active > 0) then
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
100
|
-
trimEvents(KEYS[6], KEYS[8])
|
101
|
-
|
102
103
|
return {failed, stalled}
|
@@ -77,6 +77,9 @@ local jobCounter = rcall("INCR", KEYS[4])
|
|
77
77
|
-- Includes
|
78
78
|
--- @include "includes/updateParentDepsIfNeeded"
|
79
79
|
|
80
|
+
-- Trim events before emiting them to avoid trimming events emitted in this script
|
81
|
+
trimEvents(KEYS[3], KEYS[8])
|
82
|
+
|
80
83
|
local parentDependenciesKey = args[7]
|
81
84
|
if args[2] == "" then
|
82
85
|
jobId = jobCounter
|
@@ -174,6 +177,4 @@ if parentDependenciesKey ~= nil then
|
|
174
177
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
175
178
|
end
|
176
179
|
|
177
|
-
trimEvents(KEYS[3], KEYS[8])
|
178
|
-
|
179
180
|
return jobId .. "" -- convert to string
|
@@ -42,8 +42,10 @@ local jobs = rcall(command, KEYS[1], rangeStart, rangeEnd)
|
|
42
42
|
local deleted = {}
|
43
43
|
local deletedCount = 0
|
44
44
|
local jobTS
|
45
|
+
local deletionMarker = ''
|
46
|
+
local jobIdsLen = #jobs
|
45
47
|
if ARGV[4] == "active" then
|
46
|
-
for
|
48
|
+
for i, job in ipairs(jobs) do
|
47
49
|
if limit > 0 and deletedCount >= limit then
|
48
50
|
break
|
49
51
|
end
|
@@ -52,7 +54,9 @@ if ARGV[4] == "active" then
|
|
52
54
|
if (rcall("EXISTS", jobKey .. ":lock") == 0) then
|
53
55
|
jobTS = rcall("HGET", jobKey, "timestamp")
|
54
56
|
if (not jobTS or jobTS < ARGV[2]) then
|
55
|
-
|
57
|
+
-- replace the entry with a deletion marker; the actual deletion will
|
58
|
+
-- occur at the end of the script
|
59
|
+
rcall("LSET", KEYS[1], rangeEnd - jobIdsLen + i, deletionMarker)
|
56
60
|
removeJob(job, true, ARGV[1])
|
57
61
|
deletedCount = deletedCount + 1
|
58
62
|
table.insert(deleted, job)
|
@@ -60,7 +64,7 @@ if ARGV[4] == "active" then
|
|
60
64
|
end
|
61
65
|
end
|
62
66
|
else
|
63
|
-
for
|
67
|
+
for i, job in ipairs(jobs) do
|
64
68
|
if limit > 0 and deletedCount >= limit then
|
65
69
|
break
|
66
70
|
end
|
@@ -69,7 +73,9 @@ else
|
|
69
73
|
jobTS = rcall("HGET", jobKey, "timestamp")
|
70
74
|
if (not jobTS or jobTS < ARGV[2]) then
|
71
75
|
if isList then
|
72
|
-
|
76
|
+
-- replace the entry with a deletion marker; the actual deletion will
|
77
|
+
-- occur at the end of the script
|
78
|
+
rcall("LSET", KEYS[1], rangeEnd - jobIdsLen + i, deletionMarker)
|
73
79
|
end
|
74
80
|
removeJob(job, true, ARGV[1])
|
75
81
|
deletedCount = deletedCount + 1
|
@@ -86,6 +92,10 @@ else
|
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
95
|
+
if isList then
|
96
|
+
rcall("LREM", KEYS[1], 0, deletionMarker)
|
97
|
+
end
|
98
|
+
|
89
99
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", deletedCount)
|
90
100
|
|
91
101
|
return deleted
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
local function trimEvents(metaKey, eventStreamKey)
|
6
6
|
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
|
7
|
-
if
|
7
|
+
if maxEvents ~= false then
|
8
8
|
rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)
|
9
9
|
else
|
10
10
|
rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)
|
@@ -32,6 +32,9 @@ if rcall("EXISTS", KEYS[5]) == 1 then return {{}, {}} end
|
|
32
32
|
|
33
33
|
rcall("SET", KEYS[5], ARGV[3], "PX", ARGV[4])
|
34
34
|
|
35
|
+
-- Trim events before emiting them to avoid trimming events emitted in this script
|
36
|
+
trimEvents(KEYS[6], KEYS[8])
|
37
|
+
|
35
38
|
-- Move all stalled jobs to wait
|
36
39
|
local stalling = rcall('SMEMBERS', KEYS[1])
|
37
40
|
local stalled = {}
|
@@ -97,6 +100,4 @@ if (#active > 0) then
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
100
|
-
trimEvents(KEYS[6], KEYS[8])
|
101
|
-
|
102
103
|
return {failed, stalled}
|