bullmq 5.49.2 → 5.51.0
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/classes/flow-producer.js +7 -3
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job.js +80 -40
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue.js +0 -1
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/commands/addJobScheduler-11.lua +40 -45
- package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +0 -1
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
- package/dist/cjs/commands/includes/removeJob.lua +2 -2
- package/dist/cjs/commands/includes/removeJobWithChildren.lua +2 -2
- package/dist/cjs/commands/includes/storeJob.lua +1 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +2 -2
- package/dist/cjs/commands/moveToFinished-14.lua +2 -2
- package/dist/cjs/commands/moveToWaitingChildren-8.lua +2 -2
- package/dist/cjs/commands/updateJobScheduler-12.lua +1 -1
- package/dist/cjs/scripts/addDelayedJob-6.js +1 -1
- package/dist/cjs/scripts/addJobScheduler-11.js +44 -44
- package/dist/cjs/scripts/addParentJob-4.js +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +1 -1
- package/dist/cjs/scripts/addRepeatableJob-2.js +9 -4
- package/dist/cjs/scripts/addRepeatableJob-2.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +1 -1
- package/dist/cjs/scripts/cleanJobsInSet-3.js +9 -4
- package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
- package/dist/cjs/scripts/drain-5.js +9 -4
- package/dist/cjs/scripts/drain-5.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +30 -17
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +30 -17
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +30 -17
- package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +9 -4
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeJob-3.js +9 -4
- package/dist/cjs/scripts/removeJob-3.js.map +1 -1
- package/dist/cjs/scripts/removeUnprocessedChildren-2.js +9 -4
- package/dist/cjs/scripts/removeUnprocessedChildren-2.js.map +1 -1
- package/dist/cjs/scripts/updateJobScheduler-12.js +2 -2
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/utils.js +11 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/flow-producer.js +7 -3
- package/dist/esm/classes/flow-producer.js.map +1 -1
- package/dist/esm/classes/job.d.ts +21 -6
- package/dist/esm/classes/job.js +81 -41
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +0 -1
- package/dist/esm/classes/queue.js +0 -1
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/commands/addJobScheduler-11.lua +40 -45
- package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +0 -1
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
- package/dist/esm/commands/includes/removeJob.lua +2 -2
- package/dist/esm/commands/includes/removeJobWithChildren.lua +2 -2
- package/dist/esm/commands/includes/storeJob.lua +1 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +2 -2
- package/dist/esm/commands/moveToFinished-14.lua +2 -2
- package/dist/esm/commands/moveToWaitingChildren-8.lua +2 -2
- package/dist/esm/commands/updateJobScheduler-12.lua +1 -1
- package/dist/esm/interfaces/minimal-job.d.ts +22 -8
- package/dist/esm/scripts/addDelayedJob-6.js +1 -1
- package/dist/esm/scripts/addJobScheduler-11.js +44 -44
- package/dist/esm/scripts/addParentJob-4.js +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +1 -1
- package/dist/esm/scripts/addRepeatableJob-2.js +9 -4
- package/dist/esm/scripts/addRepeatableJob-2.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +1 -1
- package/dist/esm/scripts/cleanJobsInSet-3.js +9 -4
- package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
- package/dist/esm/scripts/drain-5.js +9 -4
- package/dist/esm/scripts/drain-5.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +30 -17
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +30 -17
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +30 -17
- package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +9 -4
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeJob-3.js +9 -4
- package/dist/esm/scripts/removeJob-3.js.map +1 -1
- package/dist/esm/scripts/removeUnprocessedChildren-2.js +9 -4
- package/dist/esm/scripts/removeUnprocessedChildren-2.js.map +1 -1
- package/dist/esm/scripts/updateJobScheduler-12.js +2 -2
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils.d.ts +17 -0
- package/dist/esm/utils.js +10 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
- package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
- package/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
- package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
@@ -58,55 +58,52 @@ local prefixKey = ARGV[8]
|
|
58
58
|
local schedulerKey = repeatKey .. ":" .. jobSchedulerId
|
59
59
|
local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
60
60
|
local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
|
61
|
-
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
62
61
|
|
63
|
-
|
64
|
-
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
65
|
-
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
62
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
82
|
-
else
|
83
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
84
|
-
|
85
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
86
|
-
"duplicated", "jobId", nextDelayedJobId)
|
87
|
-
|
88
|
-
return nextDelayedJobId .. "" -- convert to string
|
89
|
-
end
|
64
|
+
local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,
|
65
|
+
metaKey, eventsKey)
|
66
|
+
if rcall("ZSCORE", delayedKey, jobId) then
|
67
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
68
|
+
rcall("ZREM", delayedKey, jobId)
|
69
|
+
return true
|
70
|
+
elseif rcall("ZSCORE", prioritizedKey, jobId) then
|
71
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
72
|
+
rcall("ZREM", prioritizedKey, jobId)
|
73
|
+
return true
|
74
|
+
else
|
75
|
+
local pausedOrWaitKey = waitKey
|
76
|
+
if isQueuePaused(metaKey) then
|
77
|
+
pausedOrWaitKey = pausedKey
|
90
78
|
end
|
79
|
+
|
80
|
+
if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then
|
81
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
82
|
+
return true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
89
|
+
if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
90
|
+
nextDelayedJobId, metaKey, eventsKey) then
|
91
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
92
|
+
"duplicated", "jobId", nextDelayedJobId)
|
93
|
+
|
94
|
+
return nextDelayedJobId .. "" -- convert to string
|
91
95
|
end
|
96
|
+
end
|
92
97
|
|
98
|
+
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
99
|
+
|
100
|
+
if prevMillis then
|
101
|
+
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
102
|
+
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
103
|
+
|
93
104
|
if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
|
94
|
-
|
95
|
-
|
96
|
-
rcall("ZREM", delayedKey, currentJobId)
|
97
|
-
elseif rcall("ZSCORE", prioritizedKey, currentJobId) ~= false then
|
98
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
99
|
-
rcall("ZREM", prioritizedKey, currentJobId)
|
100
|
-
else
|
101
|
-
local pausedOrWaitKey = waitKey
|
102
|
-
if isQueuePaused(metaKey) then
|
103
|
-
pausedOrWaitKey = pausedKey
|
104
|
-
end
|
105
|
-
|
106
|
-
if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
|
107
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
108
|
-
end
|
109
|
-
end
|
105
|
+
removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
106
|
+
currentJobId, metaKey, eventsKey)
|
110
107
|
end
|
111
108
|
end
|
112
109
|
|
@@ -115,8 +112,6 @@ storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, scheduler
|
|
115
112
|
|
116
113
|
rcall("INCR", KEYS[8])
|
117
114
|
|
118
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
119
|
-
|
120
115
|
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
|
121
116
|
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
122
117
|
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
--[[
|
2
|
+
Function to remove deduplication key if needed
|
3
|
+
when a job is moved to completed or failed states.
|
4
|
+
]]
|
5
|
+
|
6
|
+
local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
|
7
|
+
deduplicationId, jobId)
|
8
|
+
if deduplicationId then
|
9
|
+
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
10
|
+
local pttl = rcall("PTTL", deduplicationKey)
|
11
|
+
|
12
|
+
if pttl == 0 then
|
13
|
+
return rcall("DEL", deduplicationKey)
|
14
|
+
end
|
15
|
+
|
16
|
+
if pttl == -1 then
|
17
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
18
|
+
if currentJobId and currentJobId == jobId then
|
19
|
+
return rcall("DEL", deduplicationKey)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
--[[
|
2
|
+
Function to remove deduplication key if needed
|
3
|
+
when a job is being removed.
|
4
|
+
]]
|
5
|
+
|
6
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
7
|
+
jobKey, jobId)
|
8
|
+
local deduplicationId = rcall("HGET", jobKey, "deid")
|
9
|
+
if deduplicationId then
|
10
|
+
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
11
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
12
|
+
if currentJobId and currentJobId == jobId then
|
13
|
+
return rcall("DEL", deduplicationKey)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
]]
|
4
4
|
|
5
5
|
-- Includes
|
6
|
-
--- @include "
|
6
|
+
--- @include "removeDeduplicationKeyIfNeededOnRemoval"
|
7
7
|
--- @include "removeJobKeys"
|
8
8
|
--- @include "removeParentDependencyKey"
|
9
9
|
|
@@ -11,7 +11,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
11
11
|
local jobKey = baseKey .. jobId
|
12
12
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
13
13
|
if shouldRemoveDeduplicationKey then
|
14
|
-
|
14
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
15
15
|
end
|
16
16
|
removeJobKeys(jobKey)
|
17
17
|
end
|
@@ -12,7 +12,7 @@ local rcall = redis.call
|
|
12
12
|
--- @include "destructureJobKey"
|
13
13
|
--- @include "getOrSetMaxEvents"
|
14
14
|
--- @include "isJobSchedulerJob"
|
15
|
-
--- @include "
|
15
|
+
--- @include "removeDeduplicationKeyIfNeededOnRemoval"
|
16
16
|
--- @include "removeJobFromAnyState"
|
17
17
|
--- @include "removeJobKeys"
|
18
18
|
--- @include "removeParentDependencyKey"
|
@@ -84,7 +84,7 @@ removeJobWithChildren = function(prefix, meta, jobId, parentKey, options)
|
|
84
84
|
end
|
85
85
|
|
86
86
|
local prev = removeJobFromAnyState(prefix, jobId)
|
87
|
-
|
87
|
+
removeDeduplicationKeyIfNeededOnRemoval(prefix, jobKey, jobId)
|
88
88
|
if removeJobKeys(jobKey) > 0 then
|
89
89
|
local maxEvents = getOrSetMaxEvents(meta)
|
90
90
|
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
@@ -16,7 +16,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
16
16
|
table.insert(optionalValues, parentData)
|
17
17
|
end
|
18
18
|
|
19
|
-
if repeatJobKey
|
19
|
+
if repeatJobKey then
|
20
20
|
table.insert(optionalValues, "rjk")
|
21
21
|
table.insert(optionalValues, repeatJobKey)
|
22
22
|
end
|
@@ -27,7 +27,7 @@ local rcall = redis.call
|
|
27
27
|
--- @include "includes/batches"
|
28
28
|
--- @include "includes/getTargetQueueList"
|
29
29
|
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
30
|
-
--- @include "includes/
|
30
|
+
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
31
31
|
--- @include "includes/removeJobsOnFail"
|
32
32
|
--- @include "includes/trimEvents"
|
33
33
|
|
@@ -84,7 +84,7 @@ if (#stalling > 0) then
|
|
84
84
|
local rawParentData = jobAttributes[2]
|
85
85
|
local opts = cjson.decode(rawOpts)
|
86
86
|
rcall("ZADD", failedKey, timestamp, jobId)
|
87
|
-
|
87
|
+
removeDeduplicationKeyIfNeededOnFinalization(queueKeyPrefix, jobAttributes[3], jobId)
|
88
88
|
|
89
89
|
local failedReason = "job stalled more than allowable limit"
|
90
90
|
rcall("HMSET", jobKey, "failedReason", failedReason, "finishedOn", timestamp)
|
@@ -67,7 +67,7 @@ local rcall = redis.call
|
|
67
67
|
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
68
68
|
--- @include "includes/prepareJobForProcessing"
|
69
69
|
--- @include "includes/promoteDelayedJobs"
|
70
|
-
--- @include "includes/
|
70
|
+
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
71
71
|
--- @include "includes/removeJobKeys"
|
72
72
|
--- @include "includes/removeJobsByMaxAge"
|
73
73
|
--- @include "includes/removeJobsByMaxCount"
|
@@ -130,7 +130,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
130
130
|
|
131
131
|
local prefix = ARGV[7]
|
132
132
|
|
133
|
-
|
133
|
+
removeDeduplicationKeyIfNeededOnFinalization(prefix, jobAttributes[3], jobId)
|
134
134
|
|
135
135
|
-- If job has a parent we need to
|
136
136
|
-- 1) remove this job id from parents dependencies
|
@@ -37,7 +37,7 @@ local jobId = ARGV[4]
|
|
37
37
|
|
38
38
|
--- Includes
|
39
39
|
--- @include "includes/moveChildFromDependenciesIfNeeded"
|
40
|
-
--- @include "includes/
|
40
|
+
--- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
|
41
41
|
--- @include "includes/removeJobsOnFail"
|
42
42
|
--- @include "includes/removeLock"
|
43
43
|
|
@@ -61,7 +61,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
61
61
|
-- TODO: refactor this logic in an include later
|
62
62
|
local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")
|
63
63
|
|
64
|
-
|
64
|
+
removeDeduplicationKeyIfNeededOnFinalization(ARGV[5], jobAttributes[2], jobId)
|
65
65
|
|
66
66
|
local failedReason = "children are failed"
|
67
67
|
rcall("ZADD", failedKey, timestamp, jobId)
|
@@ -49,7 +49,7 @@ local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
|
49
49
|
|
50
50
|
-- Validate that scheduler exists.
|
51
51
|
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
52
|
-
if prevMillis
|
52
|
+
if prevMillis then
|
53
53
|
local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
54
54
|
|
55
55
|
if producerId == currentDelayedJobId then
|
@@ -15,15 +15,29 @@ export interface MoveToWaitingChildrenOpts {
|
|
15
15
|
queue: string;
|
16
16
|
};
|
17
17
|
}
|
18
|
+
export interface DependencyOpts {
|
19
|
+
/**
|
20
|
+
* Cursor value to be passed for pagination
|
21
|
+
*/
|
22
|
+
cursor?: number;
|
23
|
+
/**
|
24
|
+
* Max quantity of jobs to be retrieved
|
25
|
+
*/
|
26
|
+
count?: number;
|
27
|
+
}
|
18
28
|
export interface DependenciesOpts {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
29
|
+
/**
|
30
|
+
* Options for ignored child pagination
|
31
|
+
*/
|
32
|
+
ignored?: DependencyOpts;
|
33
|
+
/**
|
34
|
+
* Options for processed child pagination
|
35
|
+
*/
|
36
|
+
processed?: DependencyOpts;
|
37
|
+
/**
|
38
|
+
* Options for unprocessed child pagination
|
39
|
+
*/
|
40
|
+
unprocessed?: DependencyOpts;
|
27
41
|
}
|
28
42
|
/**
|
29
43
|
* MinimalJob
|
@@ -345,7 +345,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
345
345
|
table.insert(optionalValues, "parent")
|
346
346
|
table.insert(optionalValues, parentData)
|
347
347
|
end
|
348
|
-
if repeatJobKey
|
348
|
+
if repeatJobKey then
|
349
349
|
table.insert(optionalValues, "rjk")
|
350
350
|
table.insert(optionalValues, repeatJobKey)
|
351
351
|
end
|
@@ -158,7 +158,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
158
158
|
table.insert(optionalValues, "parent")
|
159
159
|
table.insert(optionalValues, parentData)
|
160
160
|
end
|
161
|
-
if repeatJobKey
|
161
|
+
if repeatJobKey then
|
162
162
|
table.insert(optionalValues, "rjk")
|
163
163
|
table.insert(optionalValues, repeatJobKey)
|
164
164
|
end
|
@@ -238,13 +238,18 @@ end
|
|
238
238
|
]]
|
239
239
|
-- Includes
|
240
240
|
--[[
|
241
|
-
Function to remove deduplication key
|
241
|
+
Function to remove deduplication key if needed
|
242
|
+
when a job is being removed.
|
242
243
|
]]
|
243
|
-
local function
|
244
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
245
|
+
jobKey, jobId)
|
244
246
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
245
247
|
if deduplicationId then
|
246
248
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
247
|
-
rcall(
|
249
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
250
|
+
if currentJobId and currentJobId == jobId then
|
251
|
+
return rcall("DEL", deduplicationKey)
|
252
|
+
end
|
248
253
|
end
|
249
254
|
end
|
250
255
|
--[[
|
@@ -346,7 +351,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
346
351
|
local jobKey = baseKey .. jobId
|
347
352
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
348
353
|
if shouldRemoveDeduplicationKey then
|
349
|
-
|
354
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
350
355
|
end
|
351
356
|
removeJobKeys(jobKey)
|
352
357
|
end
|
@@ -393,54 +398,49 @@ end
|
|
393
398
|
local schedulerKey = repeatKey .. ":" .. jobSchedulerId
|
394
399
|
local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
395
400
|
local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
|
401
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
402
|
+
local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,
|
403
|
+
metaKey, eventsKey)
|
404
|
+
if rcall("ZSCORE", delayedKey, jobId) then
|
405
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
406
|
+
rcall("ZREM", delayedKey, jobId)
|
407
|
+
return true
|
408
|
+
elseif rcall("ZSCORE", prioritizedKey, jobId) then
|
409
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
410
|
+
rcall("ZREM", prioritizedKey, jobId)
|
411
|
+
return true
|
412
|
+
else
|
413
|
+
local pausedOrWaitKey = waitKey
|
414
|
+
if isQueuePaused(metaKey) then
|
415
|
+
pausedOrWaitKey = pausedKey
|
416
|
+
end
|
417
|
+
if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then
|
418
|
+
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
419
|
+
return true
|
420
|
+
end
|
421
|
+
end
|
422
|
+
return false
|
423
|
+
end
|
424
|
+
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
425
|
+
if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
426
|
+
nextDelayedJobId, metaKey, eventsKey) then
|
427
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
428
|
+
"duplicated", "jobId", nextDelayedJobId)
|
429
|
+
return nextDelayedJobId .. "" -- convert to string
|
430
|
+
end
|
431
|
+
end
|
396
432
|
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
397
|
-
if prevMillis
|
433
|
+
if prevMillis then
|
398
434
|
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
399
435
|
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
400
|
-
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
401
|
-
if rcall("ZSCORE", delayedKey, nextDelayedJobId) ~= false then
|
402
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
403
|
-
rcall("ZREM", delayedKey, nextDelayedJobId)
|
404
|
-
elseif rcall("ZSCORE", prioritizedKey, nextDelayedJobId) ~= false then
|
405
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
406
|
-
rcall("ZREM", prioritizedKey, nextDelayedJobId)
|
407
|
-
else
|
408
|
-
local pausedOrWaitKey = waitKey
|
409
|
-
if isQueuePaused(metaKey) then
|
410
|
-
pausedOrWaitKey = pausedKey
|
411
|
-
end
|
412
|
-
if rcall("LREM", pausedOrWaitKey, 1, nextDelayedJobId) > 0 then
|
413
|
-
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
414
|
-
else
|
415
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
416
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
417
|
-
"duplicated", "jobId", nextDelayedJobId)
|
418
|
-
return nextDelayedJobId .. "" -- convert to string
|
419
|
-
end
|
420
|
-
end
|
421
|
-
end
|
422
436
|
if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
|
423
|
-
|
424
|
-
|
425
|
-
rcall("ZREM", delayedKey, currentJobId)
|
426
|
-
elseif rcall("ZSCORE", prioritizedKey, currentJobId) ~= false then
|
427
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
428
|
-
rcall("ZREM", prioritizedKey, currentJobId)
|
429
|
-
else
|
430
|
-
local pausedOrWaitKey = waitKey
|
431
|
-
if isQueuePaused(metaKey) then
|
432
|
-
pausedOrWaitKey = pausedKey
|
433
|
-
end
|
434
|
-
if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
|
435
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
436
|
-
end
|
437
|
-
end
|
437
|
+
removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
|
438
|
+
currentJobId, metaKey, eventsKey)
|
438
439
|
end
|
439
440
|
end
|
440
441
|
local schedulerOpts = cmsgpack.unpack(ARGV[2])
|
441
442
|
storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
|
442
443
|
rcall("INCR", KEYS[8])
|
443
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
444
444
|
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
|
445
445
|
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
446
446
|
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
@@ -301,7 +301,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
301
301
|
table.insert(optionalValues, "parent")
|
302
302
|
table.insert(optionalValues, parentData)
|
303
303
|
end
|
304
|
-
if repeatJobKey
|
304
|
+
if repeatJobKey then
|
305
305
|
table.insert(optionalValues, "rjk")
|
306
306
|
table.insert(optionalValues, repeatJobKey)
|
307
307
|
end
|
@@ -112,7 +112,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
112
112
|
table.insert(optionalValues, "parent")
|
113
113
|
table.insert(optionalValues, parentData)
|
114
114
|
end
|
115
|
-
if repeatJobKey
|
115
|
+
if repeatJobKey then
|
116
116
|
table.insert(optionalValues, "rjk")
|
117
117
|
table.insert(optionalValues, repeatJobKey)
|
118
118
|
end
|
@@ -29,13 +29,18 @@ local prefixKey = ARGV[5]
|
|
29
29
|
]]
|
30
30
|
-- Includes
|
31
31
|
--[[
|
32
|
-
Function to remove deduplication key
|
32
|
+
Function to remove deduplication key if needed
|
33
|
+
when a job is being removed.
|
33
34
|
]]
|
34
|
-
local function
|
35
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
36
|
+
jobKey, jobId)
|
35
37
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
36
38
|
if deduplicationId then
|
37
39
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
38
|
-
rcall(
|
40
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
41
|
+
if currentJobId and currentJobId == jobId then
|
42
|
+
return rcall("DEL", deduplicationKey)
|
43
|
+
end
|
39
44
|
end
|
40
45
|
end
|
41
46
|
--[[
|
@@ -173,7 +178,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
173
178
|
local jobKey = baseKey .. jobId
|
174
179
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
175
180
|
if shouldRemoveDeduplicationKey then
|
176
|
-
|
181
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
177
182
|
end
|
178
183
|
removeJobKeys(jobKey)
|
179
184
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -311,7 +311,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
311
311
|
table.insert(optionalValues, "parent")
|
312
312
|
table.insert(optionalValues, parentData)
|
313
313
|
end
|
314
|
-
if repeatJobKey
|
314
|
+
if repeatJobKey then
|
315
315
|
table.insert(optionalValues, "rjk")
|
316
316
|
table.insert(optionalValues, repeatJobKey)
|
317
317
|
end
|
@@ -65,13 +65,18 @@ end
|
|
65
65
|
]]
|
66
66
|
-- Includes
|
67
67
|
--[[
|
68
|
-
Function to remove deduplication key
|
68
|
+
Function to remove deduplication key if needed
|
69
|
+
when a job is being removed.
|
69
70
|
]]
|
70
|
-
local function
|
71
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
72
|
+
jobKey, jobId)
|
71
73
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
72
74
|
if deduplicationId then
|
73
75
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
74
|
-
rcall(
|
76
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
77
|
+
if currentJobId and currentJobId == jobId then
|
78
|
+
return rcall("DEL", deduplicationKey)
|
79
|
+
end
|
75
80
|
end
|
76
81
|
end
|
77
82
|
--[[
|
@@ -209,7 +214,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
209
214
|
local jobKey = baseKey .. jobId
|
210
215
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
211
216
|
if shouldRemoveDeduplicationKey then
|
212
|
-
|
217
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
213
218
|
end
|
214
219
|
removeJobKeys(jobKey)
|
215
220
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoWf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -37,13 +37,18 @@ end
|
|
37
37
|
]]
|
38
38
|
-- Includes
|
39
39
|
--[[
|
40
|
-
Function to remove deduplication key
|
40
|
+
Function to remove deduplication key if needed
|
41
|
+
when a job is being removed.
|
41
42
|
]]
|
42
|
-
local function
|
43
|
+
local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
|
44
|
+
jobKey, jobId)
|
43
45
|
local deduplicationId = rcall("HGET", jobKey, "deid")
|
44
46
|
if deduplicationId then
|
45
47
|
local deduplicationKey = prefixKey .. "de:" .. deduplicationId
|
46
|
-
rcall(
|
48
|
+
local currentJobId = rcall('GET', deduplicationKey)
|
49
|
+
if currentJobId and currentJobId == jobId then
|
50
|
+
return rcall("DEL", deduplicationKey)
|
51
|
+
end
|
47
52
|
end
|
48
53
|
end
|
49
54
|
--[[
|
@@ -181,7 +186,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
181
186
|
local jobKey = baseKey .. jobId
|
182
187
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
183
188
|
if shouldRemoveDeduplicationKey then
|
184
|
-
|
189
|
+
removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
|
185
190
|
end
|
186
191
|
removeJobKeys(jobKey)
|
187
192
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsQf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|