bullmq 5.1.3 → 5.1.5
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 +1 -0
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/addStandardJob-7.lua +4 -8
- package/dist/cjs/commands/changeDelay-3.lua +1 -0
- package/dist/cjs/commands/changePriority-6.lua +0 -1
- package/dist/cjs/commands/includes/addBaseMarkerIfNeeded.lua +9 -0
- package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +3 -1
- package/dist/cjs/commands/includes/addJobInTargetList.lua +11 -0
- package/dist/cjs/commands/includes/addJobWithPriority.lua +5 -3
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +6 -4
- package/dist/cjs/commands/includes/prepareJobForProcessing.lua +3 -39
- package/dist/cjs/commands/includes/promoteDelayedJobs.lua +2 -4
- package/dist/cjs/commands/moveJobsToWait-7.lua +2 -3
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +150 -0
- package/dist/cjs/commands/moveToActive-11.lua +6 -5
- package/dist/cjs/commands/moveToFinished-14.lua +13 -11
- package/dist/cjs/commands/pause-7.lua +1 -0
- package/dist/cjs/commands/promote-8.lua +2 -2
- package/dist/cjs/commands/retryJob-10.lua +1 -0
- package/dist/cjs/scripts/addDelayedJob-6.js +21 -7
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +25 -11
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-7.js +21 -7
- package/dist/cjs/scripts/addPrioritizedJob-7.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-7.js +46 -36
- package/dist/cjs/scripts/addStandardJob-7.js.map +1 -1
- package/dist/cjs/scripts/changeDelay-3.js +1 -0
- package/dist/cjs/scripts/changeDelay-3.js.map +1 -1
- package/dist/cjs/scripts/changePriority-6.js +10 -14
- package/dist/cjs/scripts/changePriority-6.js.map +1 -1
- package/dist/cjs/scripts/index.js +1 -1
- package/dist/cjs/scripts/moveJobsToWait-7.js +9 -3
- package/dist/cjs/scripts/moveJobsToWait-7.js.map +1 -1
- package/dist/cjs/scripts/{moveStalledJobsToWait-8.js → moveStalledJobsToWait-9.js} +109 -106
- package/dist/cjs/scripts/{moveStalledJobsToWait-8.js.map → moveStalledJobsToWait-9.js.map} +1 -1
- package/dist/cjs/scripts/moveToActive-11.js +28 -50
- package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
- package/dist/cjs/scripts/moveToDelayed-7.js +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +47 -70
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/pause-7.js +2 -1
- package/dist/cjs/scripts/pause-7.js.map +1 -1
- package/dist/cjs/scripts/promote-8.js +19 -5
- package/dist/cjs/scripts/promote-8.js.map +1 -1
- package/dist/cjs/scripts/retryJob-10.js +20 -7
- package/dist/cjs/scripts/retryJob-10.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/scripts.js +1 -0
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/addStandardJob-7.lua +4 -8
- package/dist/esm/commands/changeDelay-3.lua +1 -0
- package/dist/esm/commands/changePriority-6.lua +0 -1
- package/dist/esm/commands/includes/addBaseMarkerIfNeeded.lua +9 -0
- package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +3 -1
- package/dist/esm/commands/includes/addJobInTargetList.lua +11 -0
- package/dist/esm/commands/includes/addJobWithPriority.lua +5 -3
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +6 -4
- package/dist/esm/commands/includes/prepareJobForProcessing.lua +3 -39
- package/dist/esm/commands/includes/promoteDelayedJobs.lua +2 -4
- package/dist/esm/commands/moveJobsToWait-7.lua +2 -3
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +150 -0
- package/dist/esm/commands/moveToActive-11.lua +6 -5
- package/dist/esm/commands/moveToFinished-14.lua +13 -11
- package/dist/esm/commands/pause-7.lua +1 -0
- package/dist/esm/commands/promote-8.lua +2 -2
- package/dist/esm/commands/retryJob-10.lua +1 -0
- package/dist/esm/scripts/addDelayedJob-6.js +21 -7
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +25 -11
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-7.js +21 -7
- package/dist/esm/scripts/addPrioritizedJob-7.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-7.js +46 -36
- package/dist/esm/scripts/addStandardJob-7.js.map +1 -1
- package/dist/esm/scripts/changeDelay-3.js +1 -0
- package/dist/esm/scripts/changeDelay-3.js.map +1 -1
- package/dist/esm/scripts/changePriority-6.js +10 -14
- package/dist/esm/scripts/changePriority-6.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/moveJobsToWait-7.js +9 -3
- package/dist/esm/scripts/moveJobsToWait-7.js.map +1 -1
- package/dist/esm/scripts/{moveStalledJobsToWait-8.js → moveStalledJobsToWait-9.js} +109 -106
- package/dist/esm/scripts/{moveStalledJobsToWait-8.js.map → moveStalledJobsToWait-9.js.map} +1 -1
- package/dist/esm/scripts/moveToActive-11.js +28 -50
- package/dist/esm/scripts/moveToActive-11.js.map +1 -1
- package/dist/esm/scripts/moveToDelayed-7.js +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +47 -70
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/pause-7.js +2 -1
- package/dist/esm/scripts/pause-7.js.map +1 -1
- package/dist/esm/scripts/promote-8.js +19 -5
- package/dist/esm/scripts/promote-8.js.map +1 -1
- package/dist/esm/scripts/retryJob-10.js +20 -7
- package/dist/esm/scripts/retryJob-10.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/cjs/commands/includes/checkStalledJobs.lua +0 -139
- package/dist/cjs/commands/moveStalledJobsToWait-8.lua +0 -24
- package/dist/esm/commands/includes/checkStalledJobs.lua +0 -139
- package/dist/esm/commands/moveStalledJobsToWait-8.lua +0 -24
- /package/dist/esm/scripts/{moveStalledJobsToWait-8.d.ts → moveStalledJobsToWait-9.d.ts} +0 -0
@@ -25,6 +25,7 @@ local rcall = redis.call
|
|
25
25
|
local jobId = ARGV[2]
|
26
26
|
|
27
27
|
-- Includes
|
28
|
+
--- @include "includes/addJobInTargetList"
|
28
29
|
--- @include "includes/addJobWithPriority"
|
29
30
|
--- @include "includes/getTargetQueueList"
|
30
31
|
|
@@ -42,8 +43,7 @@ if rcall("ZREM", KEYS[1], jobId) == 1 then
|
|
42
43
|
|
43
44
|
if priority == 0 then
|
44
45
|
-- LIFO or FIFO
|
45
|
-
|
46
|
-
if not paused then rcall("ZADD", KEYS[8], 0, "0") end
|
46
|
+
addJobInTargetList(target, KEYS[8], "LPUSH", paused, jobId)
|
47
47
|
else
|
48
48
|
addJobWithPriority(KEYS[8], KEYS[5], priority, jobId, KEYS[6], paused)
|
49
49
|
end
|
@@ -60,6 +60,7 @@ if rcall("EXISTS", KEYS[4]) == 1 then
|
|
60
60
|
-- Standard or priority add
|
61
61
|
if priority == 0 then
|
62
62
|
rcall(ARGV[3], target, ARGV[4])
|
63
|
+
-- TODO: check if we need to add marker in this case too
|
63
64
|
else
|
64
65
|
addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9], paused)
|
65
66
|
end
|
@@ -49,7 +49,7 @@ local parentData
|
|
49
49
|
-- Includes
|
50
50
|
--[[
|
51
51
|
Add delay marker if needed.
|
52
|
-
]]
|
52
|
+
]]
|
53
53
|
-- Includes
|
54
54
|
--[[
|
55
55
|
Function to return the next delayed job timestamp.
|
@@ -130,16 +130,31 @@ end
|
|
130
130
|
Validate and move parent to active if needed.
|
131
131
|
]]
|
132
132
|
-- Includes
|
133
|
+
--[[
|
134
|
+
Function to add job in target list and add marker if needed.
|
135
|
+
]]
|
136
|
+
-- Includes
|
137
|
+
--[[
|
138
|
+
Add marker if needed when a job is available.
|
139
|
+
]]
|
140
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
141
|
+
if not isPaused then
|
142
|
+
rcall("ZADD", markerKey, 0, "0")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
146
|
+
rcall(pushCmd, targetKey, jobId)
|
147
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
148
|
+
end
|
133
149
|
--[[
|
134
150
|
Function to add job considering priority.
|
135
151
|
]]
|
152
|
+
-- Includes
|
136
153
|
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
137
154
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
138
155
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
139
156
|
rcall("ZADD", prioritizedKey, score, jobId)
|
140
|
-
|
141
|
-
rcall("ZADD", markerKey, 0, "0")
|
142
|
-
end
|
157
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
143
158
|
end
|
144
159
|
--[[
|
145
160
|
Function to check for the meta.paused key to decide if we are paused or not
|
@@ -175,11 +190,10 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
175
190
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
176
191
|
else
|
177
192
|
if priority == 0 then
|
178
|
-
local parentTarget,
|
193
|
+
local parentTarget, isParentPaused =
|
179
194
|
getTargetQueueList(parentMetaKey, parentWaitKey,
|
180
195
|
parentPausedKey)
|
181
|
-
|
182
|
-
rcall("ZADD", parentMarkerKey, 0, "0")
|
196
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
|
183
197
|
else
|
184
198
|
local isPaused = isQueuePaused(parentMetaKey)
|
185
199
|
addJobWithPriority(parentMarkerKey,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgRf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -84,7 +84,7 @@ end
|
|
84
84
|
-- Includes
|
85
85
|
--[[
|
86
86
|
Add delay marker if needed.
|
87
|
-
]]
|
87
|
+
]]
|
88
88
|
-- Includes
|
89
89
|
--[[
|
90
90
|
Function to return the next delayed job timestamp.
|
@@ -108,22 +108,37 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
--[[
|
111
|
-
Function to
|
112
|
-
(since an empty list and !EXISTS are not really the same).
|
111
|
+
Function to add job in target list and add marker if needed.
|
113
112
|
]]
|
114
|
-
|
115
|
-
|
113
|
+
-- Includes
|
114
|
+
--[[
|
115
|
+
Add marker if needed when a job is available.
|
116
|
+
]]
|
117
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
118
|
+
if not isPaused then
|
119
|
+
rcall("ZADD", markerKey, 0, "0")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
123
|
+
rcall(pushCmd, targetKey, jobId)
|
124
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
116
125
|
end
|
117
126
|
--[[
|
118
127
|
Function to add job considering priority.
|
119
128
|
]]
|
129
|
+
-- Includes
|
120
130
|
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
121
131
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
122
132
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
123
133
|
rcall("ZADD", prioritizedKey, score, jobId)
|
124
|
-
|
125
|
-
|
126
|
-
|
134
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
135
|
+
end
|
136
|
+
--[[
|
137
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
138
|
+
(since an empty list and !EXISTS are not really the same).
|
139
|
+
]]
|
140
|
+
local function isQueuePaused(queueMetaKey)
|
141
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
127
142
|
end
|
128
143
|
--[[
|
129
144
|
Function to check for the meta.paused key to decide if we are paused or not
|
@@ -159,11 +174,10 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
159
174
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
160
175
|
else
|
161
176
|
if priority == 0 then
|
162
|
-
local parentTarget,
|
177
|
+
local parentTarget, isParentPaused =
|
163
178
|
getTargetQueueList(parentMetaKey, parentWaitKey,
|
164
179
|
parentPausedKey)
|
165
|
-
|
166
|
-
rcall("ZADD", parentMarkerKey, 0, "0")
|
180
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
|
167
181
|
else
|
168
182
|
local isPaused = isQueuePaused(parentMetaKey)
|
169
183
|
addJobWithPriority(parentMarkerKey,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiQf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -82,13 +82,20 @@ end
|
|
82
82
|
--[[
|
83
83
|
Function to add job considering priority.
|
84
84
|
]]
|
85
|
+
-- Includes
|
86
|
+
--[[
|
87
|
+
Add marker if needed when a job is available.
|
88
|
+
]]
|
89
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
90
|
+
if not isPaused then
|
91
|
+
rcall("ZADD", markerKey, 0, "0")
|
92
|
+
end
|
93
|
+
end
|
85
94
|
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
86
95
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
87
96
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
88
97
|
rcall("ZADD", prioritizedKey, score, jobId)
|
89
|
-
|
90
|
-
rcall("ZADD", markerKey, 0, "0")
|
91
|
-
end
|
98
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
92
99
|
end
|
93
100
|
--[[
|
94
101
|
This function is used to update the parent's dependencies if the job
|
@@ -107,7 +114,7 @@ end
|
|
107
114
|
-- Includes
|
108
115
|
--[[
|
109
116
|
Add delay marker if needed.
|
110
|
-
]]
|
117
|
+
]]
|
111
118
|
-- Includes
|
112
119
|
--[[
|
113
120
|
Function to return the next delayed job timestamp.
|
@@ -130,6 +137,14 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
130
137
|
rcall("ZADD", markerKey, nextTimestamp, "0")
|
131
138
|
end
|
132
139
|
end
|
140
|
+
--[[
|
141
|
+
Function to add job in target list and add marker if needed.
|
142
|
+
]]
|
143
|
+
-- Includes
|
144
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
145
|
+
rcall(pushCmd, targetKey, jobId)
|
146
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
147
|
+
end
|
133
148
|
--[[
|
134
149
|
Function to check for the meta.paused key to decide if we are paused or not
|
135
150
|
(since an empty list and !EXISTS are not really the same).
|
@@ -164,11 +179,10 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
164
179
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
165
180
|
else
|
166
181
|
if priority == 0 then
|
167
|
-
local parentTarget,
|
182
|
+
local parentTarget, isParentPaused =
|
168
183
|
getTargetQueueList(parentMetaKey, parentWaitKey,
|
169
184
|
parentPausedKey)
|
170
|
-
|
171
|
-
rcall("ZADD", parentMarkerKey, 0, "0")
|
185
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
|
172
186
|
else
|
173
187
|
local isPaused = isQueuePaused(parentMetaKey)
|
174
188
|
addJobWithPriority(parentMarkerKey,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addPrioritizedJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addPrioritizedJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyQf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -51,6 +51,44 @@ local repeatJobKey = args[9]
|
|
51
51
|
local parent = args[8]
|
52
52
|
local parentData
|
53
53
|
-- Includes
|
54
|
+
--[[
|
55
|
+
Function to add job in target list and add marker if needed.
|
56
|
+
]]
|
57
|
+
-- Includes
|
58
|
+
--[[
|
59
|
+
Add marker if needed when a job is available.
|
60
|
+
]]
|
61
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
62
|
+
if not isPaused then
|
63
|
+
rcall("ZADD", markerKey, 0, "0")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
|
67
|
+
rcall(pushCmd, targetKey, jobId)
|
68
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
69
|
+
end
|
70
|
+
--[[
|
71
|
+
Function to get max events value or set by default 10000.
|
72
|
+
]]
|
73
|
+
local function getOrSetMaxEvents(metaKey)
|
74
|
+
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
|
75
|
+
if not maxEvents then
|
76
|
+
maxEvents = 10000
|
77
|
+
rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
|
78
|
+
end
|
79
|
+
return maxEvents
|
80
|
+
end
|
81
|
+
--[[
|
82
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
83
|
+
(since an empty list and !EXISTS are not really the same).
|
84
|
+
]]
|
85
|
+
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
86
|
+
if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
|
87
|
+
return waitKey, false
|
88
|
+
else
|
89
|
+
return pausedKey, true
|
90
|
+
end
|
91
|
+
end
|
54
92
|
--[[
|
55
93
|
Function to store a job
|
56
94
|
]]
|
@@ -93,7 +131,7 @@ end
|
|
93
131
|
-- Includes
|
94
132
|
--[[
|
95
133
|
Add delay marker if needed.
|
96
|
-
]]
|
134
|
+
]]
|
97
135
|
-- Includes
|
98
136
|
--[[
|
99
137
|
Function to return the next delayed job timestamp.
|
@@ -116,34 +154,22 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
116
154
|
rcall("ZADD", markerKey, nextTimestamp, "0")
|
117
155
|
end
|
118
156
|
end
|
119
|
-
--[[
|
120
|
-
Function to check for the meta.paused key to decide if we are paused or not
|
121
|
-
(since an empty list and !EXISTS are not really the same).
|
122
|
-
]]
|
123
|
-
local function isQueuePaused(queueMetaKey)
|
124
|
-
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
125
|
-
end
|
126
157
|
--[[
|
127
158
|
Function to add job considering priority.
|
128
159
|
]]
|
160
|
+
-- Includes
|
129
161
|
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
130
162
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
131
163
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
132
164
|
rcall("ZADD", prioritizedKey, score, jobId)
|
133
|
-
|
134
|
-
rcall("ZADD", markerKey, 0, "0")
|
135
|
-
end
|
165
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
136
166
|
end
|
137
167
|
--[[
|
138
168
|
Function to check for the meta.paused key to decide if we are paused or not
|
139
169
|
(since an empty list and !EXISTS are not really the same).
|
140
170
|
]]
|
141
|
-
local function
|
142
|
-
|
143
|
-
return waitKey, false
|
144
|
-
else
|
145
|
-
return pausedKey, true
|
146
|
-
end
|
171
|
+
local function isQueuePaused(queueMetaKey)
|
172
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
147
173
|
end
|
148
174
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
149
175
|
parentKey, parentId, timestamp)
|
@@ -168,11 +194,10 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
168
194
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
169
195
|
else
|
170
196
|
if priority == 0 then
|
171
|
-
local parentTarget,
|
197
|
+
local parentTarget, isParentPaused =
|
172
198
|
getTargetQueueList(parentMetaKey, parentWaitKey,
|
173
199
|
parentPausedKey)
|
174
|
-
|
175
|
-
rcall("ZADD", parentMarkerKey, 0, "0")
|
200
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
|
176
201
|
else
|
177
202
|
local isPaused = isQueuePaused(parentMetaKey)
|
178
203
|
addJobWithPriority(parentMarkerKey,
|
@@ -207,17 +232,6 @@ local function updateExistingJobsParent(parentKey, parent, parentData,
|
|
207
232
|
rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)
|
208
233
|
end
|
209
234
|
end
|
210
|
-
--[[
|
211
|
-
Function to get max events value or set by default 10000.
|
212
|
-
]]
|
213
|
-
local function getOrSetMaxEvents(metaKey)
|
214
|
-
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
|
215
|
-
if not maxEvents then
|
216
|
-
maxEvents = 10000
|
217
|
-
rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
|
218
|
-
end
|
219
|
-
return maxEvents
|
220
|
-
end
|
221
235
|
if parentKey ~= nil then
|
222
236
|
if rcall("EXISTS", parentKey) ~= 1 then return -5 end
|
223
237
|
parentData = cjson.encode(parent)
|
@@ -246,13 +260,9 @@ end
|
|
246
260
|
storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
|
247
261
|
parentKey, parentData, repeatJobKey)
|
248
262
|
local target, paused = getTargetQueueList(metaKey, KEYS[1], KEYS[2])
|
249
|
-
if not paused then
|
250
|
-
-- mark that a job is available
|
251
|
-
rcall("ZADD", KEYS[7], 0, "0")
|
252
|
-
end
|
253
263
|
-- LIFO or FIFO
|
254
264
|
local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'
|
255
|
-
|
265
|
+
addJobInTargetList(target, KEYS[7], pushCmd, paused, jobId)
|
256
266
|
-- Emit waiting event
|
257
267
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
|
258
268
|
"jobId", jobId)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addStandardJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addStandardJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Qf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -28,6 +28,7 @@ if rcall("EXISTS", KEYS[2]) == 1 then
|
|
28
28
|
end
|
29
29
|
rcall("HSET", KEYS[2], "delay", tonumber(ARGV[1]))
|
30
30
|
rcall("ZADD", KEYS[1], score, jobId)
|
31
|
+
-- TODO: check if we need to evaluate a new marker
|
31
32
|
rcall("XADD", KEYS[3], "*", "event", "delayed", "jobId", jobId, "delay", delayedTimestamp)
|
32
33
|
return 0
|
33
34
|
else
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"changeDelay-3.js","sourceRoot":"","sources":["../../../src/scripts/changeDelay-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"changeDelay-3.js","sourceRoot":"","sources":["../../../src/scripts/changeDelay-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgCZ,CAAC;AACQ,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -33,24 +33,20 @@ end
|
|
33
33
|
--[[
|
34
34
|
Function to add job considering priority.
|
35
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
|
36
45
|
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
37
46
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
38
47
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
39
48
|
rcall("ZADD", prioritizedKey, score, jobId)
|
40
|
-
|
41
|
-
rcall("ZADD", markerKey, 0, "0")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
--[[
|
45
|
-
Function to check for the meta.paused key to decide if we are paused or not
|
46
|
-
(since an empty list and !EXISTS are not really the same).
|
47
|
-
]]
|
48
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
49
|
-
if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
|
50
|
-
return waitKey, false
|
51
|
-
else
|
52
|
-
return pausedKey, true
|
53
|
-
end
|
49
|
+
addBaseMarkerIfNeeded(markerKey, isPaused)
|
54
50
|
end
|
55
51
|
if rcall("EXISTS", jobKey) == 1 then
|
56
52
|
local metaKey = KEYS[3]
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"changePriority-6.js","sourceRoot":"","sources":["../../../src/scripts/changePriority-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"changePriority-6.js","sourceRoot":"","sources":["../../../src/scripts/changePriority-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -18,7 +18,7 @@ tslib_1.__exportStar(require("./isFinished-3"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./isJobInList-1"), exports);
|
19
19
|
tslib_1.__exportStar(require("./moveJobFromActiveToWait-9"), exports);
|
20
20
|
tslib_1.__exportStar(require("./moveJobsToWait-7"), exports);
|
21
|
-
tslib_1.__exportStar(require("./moveStalledJobsToWait-
|
21
|
+
tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
|
22
22
|
tslib_1.__exportStar(require("./moveToActive-11"), exports);
|
23
23
|
tslib_1.__exportStar(require("./moveToDelayed-7"), exports);
|
24
24
|
tslib_1.__exportStar(require("./moveToFinished-14"), exports);
|
@@ -23,6 +23,14 @@ local maxCount = tonumber(ARGV[1])
|
|
23
23
|
local timestamp = tonumber(ARGV[2])
|
24
24
|
local rcall = redis.call;
|
25
25
|
-- Includes
|
26
|
+
--[[
|
27
|
+
Add marker if needed when a job is available.
|
28
|
+
]]
|
29
|
+
local function addBaseMarkerIfNeeded(markerKey, isPaused)
|
30
|
+
if not isPaused then
|
31
|
+
rcall("ZADD", markerKey, 0, "0")
|
32
|
+
end
|
33
|
+
end
|
26
34
|
--[[
|
27
35
|
Function to loop in batches.
|
28
36
|
Just a bit of warning, some commands as ZREM
|
@@ -86,9 +94,7 @@ if (#jobs > 0) then
|
|
86
94
|
rcall("ZREM", KEYS[3], unpack(jobs, from, to))
|
87
95
|
rcall("LPUSH", target, unpack(jobs, from, to))
|
88
96
|
end
|
89
|
-
|
90
|
-
rcall("ZADD", KEYS[7], 0, "0")
|
91
|
-
end
|
97
|
+
addBaseMarkerIfNeeded(KEYS[7], paused)
|
92
98
|
end
|
93
99
|
maxCount = maxCount - #jobs
|
94
100
|
if (maxCount <= 0) then return 1 end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveJobsToWait-7.js","sourceRoot":"","sources":["../../../src/scripts/moveJobsToWait-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveJobsToWait-7.js","sourceRoot":"","sources":["../../../src/scripts/moveJobsToWait-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|