bullmq 1.86.9 → 1.86.10
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/cleanJobsInSet-2.lua +2 -2
- package/dist/cjs/commands/includes/cleanSet.lua +14 -2
- package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +5 -5
- package/dist/esm/commands/cleanJobsInSet-2.lua +2 -2
- package/dist/esm/commands/includes/cleanSet.lua +14 -2
- package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +5 -5
- package/package.json +1 -1
@@ -34,11 +34,11 @@ local result
|
|
34
34
|
if ARGV[4] == "active" then
|
35
35
|
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false)
|
36
36
|
elseif ARGV[4] == "delayed" then
|
37
|
-
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], {"processedOn", "timestamp"})
|
37
|
+
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], limit, {"processedOn", "timestamp"})
|
38
38
|
elseif ARGV[4] == "wait" or ARGV[4] == "paused" then
|
39
39
|
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true)
|
40
40
|
else
|
41
|
-
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], {"finishedOn"} )
|
41
|
+
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], limit, {"finishedOn"} )
|
42
42
|
end
|
43
43
|
|
44
44
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", result[2])
|
@@ -8,8 +8,20 @@
|
|
8
8
|
--- @include "getTimestamp"
|
9
9
|
--- @include "removeJob"
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
-- We use ZRANGEBYSCORE to make the case where we're deleting a limited number
|
12
|
+
-- of items in a sorted set only run a single iteration. If we simply used
|
13
|
+
-- ZRANGE, we may take a long time traversing through jobs that are within the
|
14
|
+
-- grace period.
|
15
|
+
local function getJobs(setKey, rangeStart, rangeEnd, maxTimestamp, limit)
|
16
|
+
if limit > 0 then
|
17
|
+
return rcall("ZRANGEBYSCORE", setKey, 0, maxTimestamp, "LIMIT", 0, limit)
|
18
|
+
else
|
19
|
+
return rcall("ZRANGE", setKey, rangeStart, rangeEnd)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
local function cleanSet(setKey, jobKeyPrefix, rangeStart, rangeEnd, timestamp, limit, attributes)
|
24
|
+
local jobs = getJobs(setKey, rangeStart, rangeEnd, timestamp, limit)
|
13
25
|
local deleted = {}
|
14
26
|
local deletedCount = 0
|
15
27
|
local jobTS
|
@@ -2,6 +2,9 @@
|
|
2
2
|
Validate and move or add dependencies to parent.
|
3
3
|
]]
|
4
4
|
|
5
|
+
-- Includes
|
6
|
+
--- @include "getTargetQueueList"
|
7
|
+
|
5
8
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
6
9
|
parentId, jobIdKey, returnvalue )
|
7
10
|
local processedSet = parentKey .. ":processed"
|
@@ -9,11 +12,8 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
9
12
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
10
13
|
if rcall("SCARD", parentDependenciesKey) == 0 and activeParent then
|
11
14
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
rcall("RPUSH", parentQueueKey .. ":paused", parentId)
|
16
|
-
end
|
15
|
+
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait", parentQueueKey .. ":paused")
|
16
|
+
rcall("RPUSH", parentTarget, parentId)
|
17
17
|
|
18
18
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
19
19
|
end
|
@@ -34,11 +34,11 @@ local result
|
|
34
34
|
if ARGV[4] == "active" then
|
35
35
|
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false)
|
36
36
|
elseif ARGV[4] == "delayed" then
|
37
|
-
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], {"processedOn", "timestamp"})
|
37
|
+
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], limit, {"processedOn", "timestamp"})
|
38
38
|
elseif ARGV[4] == "wait" or ARGV[4] == "paused" then
|
39
39
|
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true)
|
40
40
|
else
|
41
|
-
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], {"finishedOn"} )
|
41
|
+
result = cleanSet(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], limit, {"finishedOn"} )
|
42
42
|
end
|
43
43
|
|
44
44
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", result[2])
|
@@ -8,8 +8,20 @@
|
|
8
8
|
--- @include "getTimestamp"
|
9
9
|
--- @include "removeJob"
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
-- We use ZRANGEBYSCORE to make the case where we're deleting a limited number
|
12
|
+
-- of items in a sorted set only run a single iteration. If we simply used
|
13
|
+
-- ZRANGE, we may take a long time traversing through jobs that are within the
|
14
|
+
-- grace period.
|
15
|
+
local function getJobs(setKey, rangeStart, rangeEnd, maxTimestamp, limit)
|
16
|
+
if limit > 0 then
|
17
|
+
return rcall("ZRANGEBYSCORE", setKey, 0, maxTimestamp, "LIMIT", 0, limit)
|
18
|
+
else
|
19
|
+
return rcall("ZRANGE", setKey, rangeStart, rangeEnd)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
local function cleanSet(setKey, jobKeyPrefix, rangeStart, rangeEnd, timestamp, limit, attributes)
|
24
|
+
local jobs = getJobs(setKey, rangeStart, rangeEnd, timestamp, limit)
|
13
25
|
local deleted = {}
|
14
26
|
local deletedCount = 0
|
15
27
|
local jobTS
|
@@ -2,6 +2,9 @@
|
|
2
2
|
Validate and move or add dependencies to parent.
|
3
3
|
]]
|
4
4
|
|
5
|
+
-- Includes
|
6
|
+
--- @include "getTargetQueueList"
|
7
|
+
|
5
8
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
6
9
|
parentId, jobIdKey, returnvalue )
|
7
10
|
local processedSet = parentKey .. ":processed"
|
@@ -9,11 +12,8 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
9
12
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
10
13
|
if rcall("SCARD", parentDependenciesKey) == 0 and activeParent then
|
11
14
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
rcall("RPUSH", parentQueueKey .. ":paused", parentId)
|
16
|
-
end
|
15
|
+
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait", parentQueueKey .. ":paused")
|
16
|
+
rcall("RPUSH", parentTarget, parentId)
|
17
17
|
|
18
18
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
19
19
|
end
|