bullmq 1.68.3 → 1.68.4
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/bullmq.d.ts +1 -1
- package/dist/cjs/classes/queue.d.ts +1 -1
- package/dist/cjs/classes/queue.js +1 -1
- package/dist/cjs/commands/cleanJobsInSet-2.lua +36 -9
- package/dist/cjs/commands/includes/getZSetItems.lua +8 -0
- package/dist/cjs/commands/includes/removeJob.lua +13 -0
- package/dist/cjs/commands/includes/removeJobs.lua +4 -10
- package/dist/cjs/commands/retryJobs-4.lua +1 -4
- package/dist/esm/classes/queue.d.ts +1 -1
- package/dist/esm/classes/queue.js +1 -1
- package/dist/esm/commands/cleanJobsInSet-2.lua +36 -9
- package/dist/esm/commands/includes/getZSetItems.lua +8 -0
- package/dist/esm/commands/includes/removeJob.lua +13 -0
- package/dist/esm/commands/includes/removeJobs.lua +4 -10
- package/dist/esm/commands/retryJobs-4.lua +1 -4
- package/package.json +1 -1
package/dist/bullmq.d.ts
CHANGED
@@ -932,7 +932,7 @@ export declare class Queue<DataType = any, ResultType = any, NameType extends st
|
|
932
932
|
* grace period.
|
933
933
|
*
|
934
934
|
* @param grace - The grace period
|
935
|
-
* @param
|
935
|
+
* @param limit - Max number of jobs to clean
|
936
936
|
* @param {string} [type=completed] - The type of job to clean
|
937
937
|
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
938
938
|
* @returns Id jobs from the deleted records
|
@@ -154,7 +154,7 @@ export declare class Queue<DataType = any, ResultType = any, NameType extends st
|
|
154
154
|
* grace period.
|
155
155
|
*
|
156
156
|
* @param grace - The grace period
|
157
|
-
* @param
|
157
|
+
* @param limit - Max number of jobs to clean
|
158
158
|
* @param {string} [type=completed] - The type of job to clean
|
159
159
|
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
160
160
|
* @returns Id jobs from the deleted records
|
@@ -170,7 +170,7 @@ class Queue extends queue_getters_1.QueueGetters {
|
|
170
170
|
* grace period.
|
171
171
|
*
|
172
172
|
* @param grace - The grace period
|
173
|
-
* @param
|
173
|
+
* @param limit - Max number of jobs to clean
|
174
174
|
* @param {string} [type=completed] - The type of job to clean
|
175
175
|
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
176
176
|
* @returns Id jobs from the deleted records
|
@@ -34,29 +34,56 @@ if limit > 0 then
|
|
34
34
|
rangeEnd = -1
|
35
35
|
end
|
36
36
|
|
37
|
+
-- Includes
|
38
|
+
--- @include "includes/batches"
|
39
|
+
--- @include "includes/removeJob"
|
40
|
+
|
37
41
|
local jobs = rcall(command, KEYS[1], rangeStart, rangeEnd)
|
38
42
|
local deleted = {}
|
39
43
|
local deletedCount = 0
|
40
44
|
local jobTS
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
if ARGV[4] == "active" then
|
46
|
+
for _, job in ipairs(jobs) do
|
47
|
+
if limit > 0 and deletedCount >= limit then
|
48
|
+
break
|
49
|
+
end
|
50
|
+
|
51
|
+
local jobKey = ARGV[1] .. job
|
52
|
+
if (rcall("EXISTS", jobKey .. ":lock") == 0) then
|
53
|
+
jobTS = rcall("HGET", jobKey, "timestamp")
|
54
|
+
if (not jobTS or jobTS < ARGV[2]) then
|
55
|
+
rcall("LREM", KEYS[1], 0, job)
|
56
|
+
removeJob(job, true, ARGV[1])
|
57
|
+
deletedCount = deletedCount + 1
|
58
|
+
table.insert(deleted, job)
|
59
|
+
end
|
60
|
+
end
|
44
61
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
62
|
+
else
|
63
|
+
for _, job in ipairs(jobs) do
|
64
|
+
if limit > 0 and deletedCount >= limit then
|
65
|
+
break
|
66
|
+
end
|
67
|
+
|
68
|
+
local jobKey = ARGV[1] .. job
|
48
69
|
jobTS = rcall("HGET", jobKey, "timestamp")
|
49
70
|
if (not jobTS or jobTS < ARGV[2]) then
|
50
71
|
if isList then
|
51
72
|
rcall("LREM", KEYS[1], 0, job)
|
52
|
-
else
|
53
|
-
rcall("ZREM", KEYS[1], job)
|
54
73
|
end
|
55
|
-
|
74
|
+
removeJob(job, true, ARGV[1])
|
56
75
|
deletedCount = deletedCount + 1
|
57
76
|
table.insert(deleted, job)
|
58
77
|
end
|
59
78
|
end
|
79
|
+
|
80
|
+
if not isList then
|
81
|
+
if(#deleted > 0) then
|
82
|
+
for from, to in batches(#deleted, 7000) do
|
83
|
+
rcall("ZREM", KEYS[1], unpack(deleted, from, to))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
60
87
|
end
|
61
88
|
|
62
89
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", deletedCount)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
--[[
|
2
|
+
Function to remove job.
|
3
|
+
]]
|
4
|
+
|
5
|
+
-- Includes
|
6
|
+
--- @include "removeParentDependencyKey"
|
7
|
+
|
8
|
+
local function removeJob(key, hard, baseKey)
|
9
|
+
local jobKey = baseKey .. key
|
10
|
+
removeParentDependencyKey(jobKey, hard, baseKey)
|
11
|
+
rcall("DEL", jobKey, jobKey .. ':logs',
|
12
|
+
jobKey .. ':dependencies', jobKey .. ':processed')
|
13
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
--[[
|
2
|
-
Functions remove jobs.
|
2
|
+
Functions to remove jobs.
|
3
3
|
]]
|
4
4
|
|
5
5
|
-- Includes
|
@@ -9,18 +9,12 @@ local function getListItems(keyName, max)
|
|
9
9
|
return rcall('LRANGE', keyName, 0, max - 1)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
--- @include "removeParentDependencyKey"
|
12
|
+
--- @include "getZSetItems"
|
13
|
+
--- @include "removeJob"
|
17
14
|
|
18
15
|
local function removeJobs(keys, hard, baseKey, max)
|
19
16
|
for i, key in ipairs(keys) do
|
20
|
-
|
21
|
-
removeParentDependencyKey(jobKey, hard, baseKey)
|
22
|
-
rcall("DEL", jobKey, jobKey .. ':logs',
|
23
|
-
jobKey .. ':dependencies', jobKey .. ':processed')
|
17
|
+
removeJob(key, hard, baseKey)
|
24
18
|
end
|
25
19
|
return max - #keys
|
26
20
|
end
|
@@ -20,10 +20,7 @@ local rcall = redis.call;
|
|
20
20
|
|
21
21
|
-- Includes
|
22
22
|
--- @include "includes/batches"
|
23
|
-
|
24
|
-
local function getZSetItems(keyName, max)
|
25
|
-
return rcall('ZRANGE', keyName, 0, max - 1)
|
26
|
-
end
|
23
|
+
--- @include "includes/getZSetItems"
|
27
24
|
|
28
25
|
local jobs = getZSetItems(KEYS[3], maxCount)
|
29
26
|
|
@@ -154,7 +154,7 @@ export declare class Queue<DataType = any, ResultType = any, NameType extends st
|
|
154
154
|
* grace period.
|
155
155
|
*
|
156
156
|
* @param grace - The grace period
|
157
|
-
* @param
|
157
|
+
* @param limit - Max number of jobs to clean
|
158
158
|
* @param {string} [type=completed] - The type of job to clean
|
159
159
|
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
160
160
|
* @returns Id jobs from the deleted records
|
@@ -167,7 +167,7 @@ export class Queue extends QueueGetters {
|
|
167
167
|
* grace period.
|
168
168
|
*
|
169
169
|
* @param grace - The grace period
|
170
|
-
* @param
|
170
|
+
* @param limit - Max number of jobs to clean
|
171
171
|
* @param {string} [type=completed] - The type of job to clean
|
172
172
|
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
173
173
|
* @returns Id jobs from the deleted records
|
@@ -34,29 +34,56 @@ if limit > 0 then
|
|
34
34
|
rangeEnd = -1
|
35
35
|
end
|
36
36
|
|
37
|
+
-- Includes
|
38
|
+
--- @include "includes/batches"
|
39
|
+
--- @include "includes/removeJob"
|
40
|
+
|
37
41
|
local jobs = rcall(command, KEYS[1], rangeStart, rangeEnd)
|
38
42
|
local deleted = {}
|
39
43
|
local deletedCount = 0
|
40
44
|
local jobTS
|
41
|
-
|
42
|
-
|
43
|
-
|
45
|
+
if ARGV[4] == "active" then
|
46
|
+
for _, job in ipairs(jobs) do
|
47
|
+
if limit > 0 and deletedCount >= limit then
|
48
|
+
break
|
49
|
+
end
|
50
|
+
|
51
|
+
local jobKey = ARGV[1] .. job
|
52
|
+
if (rcall("EXISTS", jobKey .. ":lock") == 0) then
|
53
|
+
jobTS = rcall("HGET", jobKey, "timestamp")
|
54
|
+
if (not jobTS or jobTS < ARGV[2]) then
|
55
|
+
rcall("LREM", KEYS[1], 0, job)
|
56
|
+
removeJob(job, true, ARGV[1])
|
57
|
+
deletedCount = deletedCount + 1
|
58
|
+
table.insert(deleted, job)
|
59
|
+
end
|
60
|
+
end
|
44
61
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
62
|
+
else
|
63
|
+
for _, job in ipairs(jobs) do
|
64
|
+
if limit > 0 and deletedCount >= limit then
|
65
|
+
break
|
66
|
+
end
|
67
|
+
|
68
|
+
local jobKey = ARGV[1] .. job
|
48
69
|
jobTS = rcall("HGET", jobKey, "timestamp")
|
49
70
|
if (not jobTS or jobTS < ARGV[2]) then
|
50
71
|
if isList then
|
51
72
|
rcall("LREM", KEYS[1], 0, job)
|
52
|
-
else
|
53
|
-
rcall("ZREM", KEYS[1], job)
|
54
73
|
end
|
55
|
-
|
74
|
+
removeJob(job, true, ARGV[1])
|
56
75
|
deletedCount = deletedCount + 1
|
57
76
|
table.insert(deleted, job)
|
58
77
|
end
|
59
78
|
end
|
79
|
+
|
80
|
+
if not isList then
|
81
|
+
if(#deleted > 0) then
|
82
|
+
for from, to in batches(#deleted, 7000) do
|
83
|
+
rcall("ZREM", KEYS[1], unpack(deleted, from, to))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
60
87
|
end
|
61
88
|
|
62
89
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", deletedCount)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
--[[
|
2
|
+
Function to remove job.
|
3
|
+
]]
|
4
|
+
|
5
|
+
-- Includes
|
6
|
+
--- @include "removeParentDependencyKey"
|
7
|
+
|
8
|
+
local function removeJob(key, hard, baseKey)
|
9
|
+
local jobKey = baseKey .. key
|
10
|
+
removeParentDependencyKey(jobKey, hard, baseKey)
|
11
|
+
rcall("DEL", jobKey, jobKey .. ':logs',
|
12
|
+
jobKey .. ':dependencies', jobKey .. ':processed')
|
13
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
--[[
|
2
|
-
Functions remove jobs.
|
2
|
+
Functions to remove jobs.
|
3
3
|
]]
|
4
4
|
|
5
5
|
-- Includes
|
@@ -9,18 +9,12 @@ local function getListItems(keyName, max)
|
|
9
9
|
return rcall('LRANGE', keyName, 0, max - 1)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
--- @include "removeParentDependencyKey"
|
12
|
+
--- @include "getZSetItems"
|
13
|
+
--- @include "removeJob"
|
17
14
|
|
18
15
|
local function removeJobs(keys, hard, baseKey, max)
|
19
16
|
for i, key in ipairs(keys) do
|
20
|
-
|
21
|
-
removeParentDependencyKey(jobKey, hard, baseKey)
|
22
|
-
rcall("DEL", jobKey, jobKey .. ':logs',
|
23
|
-
jobKey .. ':dependencies', jobKey .. ':processed')
|
17
|
+
removeJob(key, hard, baseKey)
|
24
18
|
end
|
25
19
|
return max - #keys
|
26
20
|
end
|
@@ -20,10 +20,7 @@ local rcall = redis.call;
|
|
20
20
|
|
21
21
|
-- Includes
|
22
22
|
--- @include "includes/batches"
|
23
|
-
|
24
|
-
local function getZSetItems(keyName, max)
|
25
|
-
return rcall('ZRANGE', keyName, 0, max - 1)
|
26
|
-
end
|
23
|
+
--- @include "includes/getZSetItems"
|
27
24
|
|
28
25
|
local jobs = getZSetItems(KEYS[3], maxCount)
|
29
26
|
|