bullmq 5.1.7 → 5.1.9
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/scripts.js +12 -5
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/changeDelay-4.lua +57 -0
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +7 -3
- package/dist/cjs/scripts/changeDelay-4.js +94 -0
- package/dist/cjs/scripts/changeDelay-4.js.map +1 -0
- package/dist/cjs/scripts/cleanJobsInSet-2.js +22 -3
- package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/cjs/scripts/drain-4.js +22 -3
- package/dist/cjs/scripts/drain-4.js.map +1 -1
- package/dist/cjs/scripts/index.js +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +6 -3
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +6 -3
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +22 -3
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeJob-1.js +22 -3
- package/dist/cjs/scripts/removeJob-1.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/scripts.js +12 -5
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/changeDelay-4.lua +57 -0
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +7 -3
- package/dist/esm/scripts/changeDelay-4.js +91 -0
- package/dist/esm/scripts/changeDelay-4.js.map +1 -0
- package/dist/esm/scripts/cleanJobsInSet-2.js +22 -3
- package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/esm/scripts/drain-4.js +22 -3
- package/dist/esm/scripts/drain-4.js.map +1 -1
- package/dist/esm/scripts/index.d.ts +1 -1
- package/dist/esm/scripts/index.js +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +6 -3
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +6 -3
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +22 -3
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeJob-1.js +22 -3
- package/dist/esm/scripts/removeJob-1.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/cjs/commands/changeDelay-3.lua +0 -41
- package/dist/cjs/scripts/changeDelay-3.js +0 -42
- package/dist/cjs/scripts/changeDelay-3.js.map +0 -1
- package/dist/esm/commands/changeDelay-3.lua +0 -41
- package/dist/esm/scripts/changeDelay-3.js +0 -39
- package/dist/esm/scripts/changeDelay-3.js.map +0 -1
- /package/dist/esm/scripts/{changeDelay-3.d.ts → changeDelay-4.d.ts} +0 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
const content = `--[[
|
2
|
+
Change job delay when it is in delayed set.
|
3
|
+
Input:
|
4
|
+
KEYS[1] delayed key
|
5
|
+
KEYS[2] meta key
|
6
|
+
KEYS[3] marker key
|
7
|
+
KEYS[4] events stream
|
8
|
+
ARGV[1] delay
|
9
|
+
ARGV[2] delayedTimestamp
|
10
|
+
ARGV[3] the id of the job
|
11
|
+
ARGV[4] job key
|
12
|
+
Output:
|
13
|
+
0 - OK
|
14
|
+
-1 - Missing job.
|
15
|
+
-3 - Job not in delayed set.
|
16
|
+
Events:
|
17
|
+
- delayed key.
|
18
|
+
]]
|
19
|
+
local rcall = redis.call
|
20
|
+
-- Includes
|
21
|
+
--[[
|
22
|
+
Add delay marker if needed.
|
23
|
+
]]
|
24
|
+
-- Includes
|
25
|
+
--[[
|
26
|
+
Function to return the next delayed job timestamp.
|
27
|
+
]]
|
28
|
+
local function getNextDelayedTimestamp(delayedKey)
|
29
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
30
|
+
if #result then
|
31
|
+
local nextTimestamp = tonumber(result[2])
|
32
|
+
if (nextTimestamp ~= nil) then
|
33
|
+
nextTimestamp = nextTimestamp / 0x1000
|
34
|
+
end
|
35
|
+
return nextTimestamp
|
36
|
+
end
|
37
|
+
end
|
38
|
+
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
39
|
+
local nextTimestamp = getNextDelayedTimestamp(delayedKey)
|
40
|
+
if nextTimestamp ~= nil then
|
41
|
+
-- Replace the score of the marker with the newest known
|
42
|
+
-- next timestamp.
|
43
|
+
rcall("ZADD", markerKey, nextTimestamp, "0")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
--[[
|
47
|
+
Function to get max events value or set by default 10000.
|
48
|
+
]]
|
49
|
+
local function getOrSetMaxEvents(metaKey)
|
50
|
+
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
|
51
|
+
if not maxEvents then
|
52
|
+
maxEvents = 10000
|
53
|
+
rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
|
54
|
+
end
|
55
|
+
return maxEvents
|
56
|
+
end
|
57
|
+
--[[
|
58
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
59
|
+
(since an empty list and !EXISTS are not really the same).
|
60
|
+
]]
|
61
|
+
local function isQueuePaused(queueMetaKey)
|
62
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
63
|
+
end
|
64
|
+
if rcall("EXISTS", ARGV[4]) == 1 then
|
65
|
+
local jobId = ARGV[3]
|
66
|
+
local score = tonumber(ARGV[2])
|
67
|
+
local delayedTimestamp = (score / 0x1000)
|
68
|
+
local numRemovedElements = rcall("ZREM", KEYS[1], jobId)
|
69
|
+
if numRemovedElements < 1 then
|
70
|
+
return -3
|
71
|
+
end
|
72
|
+
rcall("HSET", ARGV[4], "delay", tonumber(ARGV[1]))
|
73
|
+
rcall("ZADD", KEYS[1], score, jobId)
|
74
|
+
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
75
|
+
rcall("XADD", KEYS[4], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
76
|
+
"jobId", jobId, "delay", delayedTimestamp)
|
77
|
+
-- mark that a delayed job is available
|
78
|
+
local isPaused = isQueuePaused(KEYS[2])
|
79
|
+
if not isPaused then
|
80
|
+
addDelayMarkerIfNeeded(KEYS[3], KEYS[1])
|
81
|
+
end
|
82
|
+
return 0
|
83
|
+
else
|
84
|
+
return -1
|
85
|
+
end`;
|
86
|
+
export const changeDelay = {
|
87
|
+
name: 'changeDelay',
|
88
|
+
content,
|
89
|
+
keys: 4,
|
90
|
+
};
|
91
|
+
//# sourceMappingURL=changeDelay-4.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"changeDelay-4.js","sourceRoot":"","sources":["../../../src/scripts/changeDelay-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoFZ,CAAC;AACL,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -52,6 +52,23 @@ end
|
|
52
52
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
53
53
|
which requires code from "moveToFinished"
|
54
54
|
]]
|
55
|
+
-- Includes
|
56
|
+
--[[
|
57
|
+
Function to add job in target list and add marker if needed.
|
58
|
+
]]
|
59
|
+
-- Includes
|
60
|
+
--[[
|
61
|
+
Add marker if needed when a job is available.
|
62
|
+
]]
|
63
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
64
|
+
if not isPaused then
|
65
|
+
rcall("ZADD", markerKey, 0, "0")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
69
|
+
rcall(pushCmd, targetKey, jobId)
|
70
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
71
|
+
end
|
55
72
|
--[[
|
56
73
|
Functions to destructure job key.
|
57
74
|
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
@@ -74,8 +91,9 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
|
74
91
|
end
|
75
92
|
end
|
76
93
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
77
|
-
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
78
|
-
|
94
|
+
local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
95
|
+
parentPrefix .. "paused")
|
96
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
|
79
97
|
if emitEvent then
|
80
98
|
local parentEventStream = parentPrefix .. "events"
|
81
99
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -108,7 +126,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
108
126
|
end
|
109
127
|
else
|
110
128
|
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
111
|
-
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
129
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
130
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
112
131
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
113
132
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
114
133
|
if result > 0 then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Rf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -27,6 +27,23 @@ local queueBaseKey = ARGV[1]
|
|
27
27
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
28
28
|
which requires code from "moveToFinished"
|
29
29
|
]]
|
30
|
+
-- Includes
|
31
|
+
--[[
|
32
|
+
Function to add job in target list and add marker if needed.
|
33
|
+
]]
|
34
|
+
-- Includes
|
35
|
+
--[[
|
36
|
+
Add marker if needed when a job is available.
|
37
|
+
]]
|
38
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
39
|
+
if not isPaused then
|
40
|
+
rcall("ZADD", markerKey, 0, "0")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
44
|
+
rcall(pushCmd, targetKey, jobId)
|
45
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
46
|
+
end
|
30
47
|
--[[
|
31
48
|
Functions to destructure job key.
|
32
49
|
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
@@ -49,8 +66,9 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
|
49
66
|
end
|
50
67
|
end
|
51
68
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
52
|
-
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
53
|
-
|
69
|
+
local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
70
|
+
parentPrefix .. "paused")
|
71
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
|
54
72
|
if emitEvent then
|
55
73
|
local parentEventStream = parentPrefix .. "events"
|
56
74
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -83,7 +101,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
83
101
|
end
|
84
102
|
else
|
85
103
|
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
86
|
-
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
104
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
105
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
87
106
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
88
107
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
89
108
|
if result > 0 then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Lf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -2,7 +2,7 @@ export * from './addDelayedJob-6';
|
|
2
2
|
export * from './addParentJob-4';
|
3
3
|
export * from './addPrioritizedJob-7';
|
4
4
|
export * from './addStandardJob-7';
|
5
|
-
export * from './changeDelay-
|
5
|
+
export * from './changeDelay-4';
|
6
6
|
export * from './changePriority-6';
|
7
7
|
export * from './cleanJobsInSet-2';
|
8
8
|
export * from './drain-4';
|
@@ -2,7 +2,7 @@ export * from './addDelayedJob-6';
|
|
2
2
|
export * from './addParentJob-4';
|
3
3
|
export * from './addPrioritizedJob-7';
|
4
4
|
export * from './addStandardJob-7';
|
5
|
-
export * from './changeDelay-
|
5
|
+
export * from './changeDelay-4';
|
6
6
|
export * from './changePriority-6';
|
7
7
|
export * from './cleanJobsInSet-2';
|
8
8
|
export * from './drain-4';
|
@@ -71,6 +71,7 @@ end
|
|
71
71
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
72
72
|
which requires code from "moveToFinished"
|
73
73
|
]]
|
74
|
+
-- Includes
|
74
75
|
--[[
|
75
76
|
Functions to destructure job key.
|
76
77
|
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
@@ -82,8 +83,9 @@ local getJobKeyPrefix = function (jobKey, jobId)
|
|
82
83
|
return string.sub(jobKey, 0, #jobKey - #jobId)
|
83
84
|
end
|
84
85
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
85
|
-
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
86
|
-
|
86
|
+
local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
87
|
+
parentPrefix .. "paused")
|
88
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
|
87
89
|
if emitEvent then
|
88
90
|
local parentEventStream = parentPrefix .. "events"
|
89
91
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -116,7 +118,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
116
118
|
end
|
117
119
|
else
|
118
120
|
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
119
|
-
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
121
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
122
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
120
123
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
121
124
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
122
125
|
if result > 0 then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA0SS,CAAC;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -329,6 +329,7 @@ end
|
|
329
329
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
330
330
|
which requires code from "moveToFinished"
|
331
331
|
]]
|
332
|
+
-- Includes
|
332
333
|
--[[
|
333
334
|
Functions to destructure job key.
|
334
335
|
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
@@ -340,8 +341,9 @@ local getJobKeyPrefix = function (jobKey, jobId)
|
|
340
341
|
return string.sub(jobKey, 0, #jobKey - #jobId)
|
341
342
|
end
|
342
343
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
343
|
-
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
344
|
-
|
344
|
+
local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
345
|
+
parentPrefix .. "paused")
|
346
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
|
345
347
|
if emitEvent then
|
346
348
|
local parentEventStream = parentPrefix .. "events"
|
347
349
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -374,7 +376,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
374
376
|
end
|
375
377
|
else
|
376
378
|
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
377
|
-
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
379
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
380
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
378
381
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
379
382
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
380
383
|
if result > 0 then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4oBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -29,6 +29,23 @@ local rcall = redis.call
|
|
29
29
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
30
30
|
which requires code from "moveToFinished"
|
31
31
|
]]
|
32
|
+
-- Includes
|
33
|
+
--[[
|
34
|
+
Function to add job in target list and add marker if needed.
|
35
|
+
]]
|
36
|
+
-- Includes
|
37
|
+
--[[
|
38
|
+
Add marker if needed when a job is available.
|
39
|
+
]]
|
40
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
41
|
+
if not isPaused then
|
42
|
+
rcall("ZADD", markerKey, 0, "0")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
46
|
+
rcall(pushCmd, targetKey, jobId)
|
47
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
48
|
+
end
|
32
49
|
--[[
|
33
50
|
Functions to destructure job key.
|
34
51
|
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
@@ -51,8 +68,9 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
|
51
68
|
end
|
52
69
|
end
|
53
70
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
54
|
-
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
55
|
-
|
71
|
+
local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
72
|
+
parentPrefix .. "paused")
|
73
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
|
56
74
|
if emitEvent then
|
57
75
|
local parentEventStream = parentPrefix .. "events"
|
58
76
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -85,7 +103,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
85
103
|
end
|
86
104
|
else
|
87
105
|
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
88
|
-
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
106
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
107
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
89
108
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
90
109
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
91
110
|
if result > 0 then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiQf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -98,6 +98,23 @@ end
|
|
98
98
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
99
99
|
which requires code from "moveToFinished"
|
100
100
|
]]
|
101
|
+
-- Includes
|
102
|
+
--[[
|
103
|
+
Function to add job in target list and add marker if needed.
|
104
|
+
]]
|
105
|
+
-- Includes
|
106
|
+
--[[
|
107
|
+
Add marker if needed when a job is available.
|
108
|
+
]]
|
109
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
110
|
+
if not isPaused then
|
111
|
+
rcall("ZADD", markerKey, 0, "0")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
115
|
+
rcall(pushCmd, targetKey, jobId)
|
116
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
117
|
+
end
|
101
118
|
--[[
|
102
119
|
Function to check for the meta.paused key to decide if we are paused or not
|
103
120
|
(since an empty list and !EXISTS are not really the same).
|
@@ -110,8 +127,9 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
|
110
127
|
end
|
111
128
|
end
|
112
129
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
113
|
-
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
114
|
-
|
130
|
+
local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
|
131
|
+
parentPrefix .. "paused")
|
132
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
|
115
133
|
if emitEvent then
|
116
134
|
local parentEventStream = parentPrefix .. "events"
|
117
135
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -144,7 +162,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
144
162
|
end
|
145
163
|
else
|
146
164
|
local missedParentKey = rcall("HGET", jobKey, "parentKey")
|
147
|
-
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
165
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
166
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
148
167
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
149
168
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
150
169
|
if result > 0 then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuOf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|