bullmq 5.1.2 → 5.1.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/cjs/classes/scripts.js +3 -1
- 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/promoteDelayedJobs.lua +2 -4
- package/dist/{esm/commands/moveJobsToWait-6.lua → cjs/commands/moveJobsToWait-7.lua} +5 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +150 -0
- package/dist/cjs/commands/moveToFinished-14.lua +1 -0
- 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 +2 -2
- package/dist/cjs/scripts/{moveJobsToWait-6.js → moveJobsToWait-7.js} +13 -3
- package/dist/cjs/scripts/moveJobsToWait-7.js.map +1 -0
- 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 +19 -7
- 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 +32 -21
- 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 +3 -1
- 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/promoteDelayedJobs.lua +2 -4
- package/dist/{cjs/commands/moveJobsToWait-6.lua → esm/commands/moveJobsToWait-7.lua} +5 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +150 -0
- package/dist/esm/commands/moveToFinished-14.lua +1 -0
- 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 +2 -2
- package/dist/esm/scripts/index.js +2 -2
- package/dist/esm/scripts/{moveJobsToWait-6.js → moveJobsToWait-7.js} +13 -3
- package/dist/esm/scripts/moveJobsToWait-7.js.map +1 -0
- 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 +19 -7
- 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 +32 -21
- 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/cjs/scripts/moveJobsToWait-6.js.map +0 -1
- package/dist/esm/commands/includes/checkStalledJobs.lua +0 -139
- package/dist/esm/commands/moveStalledJobsToWait-8.lua +0 -24
- package/dist/esm/scripts/moveJobsToWait-6.js.map +0 -1
- /package/dist/esm/scripts/{moveJobsToWait-6.d.ts → moveJobsToWait-7.d.ts} +0 -0
- /package/dist/esm/scripts/{moveStalledJobsToWait-8.d.ts → moveStalledJobsToWait-9.d.ts} +0 -0
@@ -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"}
|
@@ -17,8 +17,8 @@ tslib_1.__exportStar(require("./getStateV2-8"), exports);
|
|
17
17
|
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
|
-
tslib_1.__exportStar(require("./moveJobsToWait-
|
21
|
-
tslib_1.__exportStar(require("./moveStalledJobsToWait-
|
20
|
+
tslib_1.__exportStar(require("./moveJobsToWait-7"), exports);
|
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);
|
@@ -11,6 +11,7 @@ const content = `--[[
|
|
11
11
|
KEYS[4] 'wait'
|
12
12
|
KEYS[5] 'paused'
|
13
13
|
KEYS[6] 'meta'
|
14
|
+
KEYS[7] 'marker'
|
14
15
|
ARGV[1] count
|
15
16
|
ARGV[2] timestamp
|
16
17
|
ARGV[3] prev state
|
@@ -22,6 +23,14 @@ local maxCount = tonumber(ARGV[1])
|
|
22
23
|
local timestamp = tonumber(ARGV[2])
|
23
24
|
local rcall = redis.call;
|
24
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
|
25
34
|
--[[
|
26
35
|
Function to loop in batches.
|
27
36
|
Just a bit of warning, some commands as ZREM
|
@@ -61,7 +70,7 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
|
61
70
|
end
|
62
71
|
end
|
63
72
|
local metaKey = KEYS[6]
|
64
|
-
local target = getTargetQueueList(metaKey, KEYS[4], KEYS[5])
|
73
|
+
local target, paused = getTargetQueueList(metaKey, KEYS[4], KEYS[5])
|
65
74
|
local jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)
|
66
75
|
if (#jobs > 0) then
|
67
76
|
if ARGV[3] == "failed" then
|
@@ -85,6 +94,7 @@ if (#jobs > 0) then
|
|
85
94
|
rcall("ZREM", KEYS[3], unpack(jobs, from, to))
|
86
95
|
rcall("LPUSH", target, unpack(jobs, from, to))
|
87
96
|
end
|
97
|
+
addBaseMarkerIfNeeded(KEYS[7], paused)
|
88
98
|
end
|
89
99
|
maxCount = maxCount - #jobs
|
90
100
|
if (maxCount <= 0) then return 1 end
|
@@ -93,6 +103,6 @@ return 0
|
|
93
103
|
exports.moveJobsToWait = {
|
94
104
|
name: 'moveJobsToWait',
|
95
105
|
content,
|
96
|
-
keys:
|
106
|
+
keys: 7,
|
97
107
|
};
|
98
|
-
//# sourceMappingURL=moveJobsToWait-
|
108
|
+
//# sourceMappingURL=moveJobsToWait-7.js.map
|
@@ -0,0 +1 @@
|
|
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"}
|