bullmq 3.1.3 → 3.2.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/commands/addJob-8.lua +2 -2
- package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +18 -3
- package/dist/cjs/commands/moveToFinished-12.lua +1 -2
- package/dist/cjs/interfaces/base-job-options.d.ts +2 -2
- package/dist/cjs/scripts/addJob-8.js +18 -5
- package/dist/cjs/scripts/addJob-8.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-12.js +17 -5
- package/dist/cjs/scripts/moveToFinished-12.js.map +1 -1
- package/dist/esm/commands/addJob-8.lua +2 -2
- package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +18 -3
- package/dist/esm/commands/moveToFinished-12.lua +1 -2
- package/dist/esm/interfaces/base-job-options.d.ts +2 -2
- package/dist/esm/scripts/addJob-8.js +18 -5
- package/dist/esm/scripts/addJob-8.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-12.js +17 -5
- package/dist/esm/scripts/moveToFinished-12.js.map +1 -1
- package/package.json +1 -1
@@ -79,6 +79,7 @@ local jobCounter = rcall("INCR", KEYS[4])
|
|
79
79
|
trimEvents(KEYS[3], KEYS[8])
|
80
80
|
|
81
81
|
local parentDependenciesKey = args[7]
|
82
|
+
local timestamp = args[4]
|
82
83
|
if args[2] == "" then
|
83
84
|
jobId = jobCounter
|
84
85
|
jobIdKey = args[1] .. jobId
|
@@ -90,7 +91,7 @@ else
|
|
90
91
|
if rcall("ZSCORE", KEYS[7], jobId) ~= false then
|
91
92
|
local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
|
92
93
|
updateParentDepsIfNeeded(parentKey, parent['queueKey'], parentDependenciesKey,
|
93
|
-
parent['id'], jobIdKey, returnvalue)
|
94
|
+
parent['id'], jobIdKey, returnvalue, timestamp)
|
94
95
|
else
|
95
96
|
if parentDependenciesKey ~= nil then
|
96
97
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
@@ -106,7 +107,6 @@ end
|
|
106
107
|
local jsonOpts = cjson.encode(opts)
|
107
108
|
local delay = opts['delay'] or 0
|
108
109
|
local priority = opts['priority'] or 0
|
109
|
-
local timestamp = args[4]
|
110
110
|
|
111
111
|
local optionalValues = {}
|
112
112
|
if parentKey ~= nil then
|
@@ -4,10 +4,11 @@
|
|
4
4
|
|
5
5
|
-- Includes
|
6
6
|
--- @include "addJobWithPriority"
|
7
|
+
--- @include "getNextDelayedTimestamp"
|
7
8
|
--- @include "getTargetQueueList"
|
8
9
|
|
9
10
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
10
|
-
parentId, jobIdKey, returnvalue )
|
11
|
+
parentId, jobIdKey, returnvalue, timestamp )
|
11
12
|
local processedSet = parentKey .. ":processed"
|
12
13
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
13
14
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
@@ -15,9 +16,23 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
15
16
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
16
17
|
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait",
|
17
18
|
parentQueueKey .. ":paused")
|
18
|
-
local
|
19
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
20
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
21
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
22
|
+
if delay > 0 then
|
23
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
24
|
+
local score = delayedTimestamp * 0x1000
|
25
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
26
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
27
|
+
|
28
|
+
if rcall("LLEN", parentTarget) == 0 then
|
29
|
+
local nextTimestamp = getNextDelayedTimestamp(parentDelayedKey)
|
30
|
+
if not nextTimestamp or (delayedTimestamp <= nextTimestamp) then
|
31
|
+
rcall("LPUSH", parentTarget, "0:" .. delayedTimestamp - tonumber(timestamp))
|
32
|
+
end
|
33
|
+
end
|
19
34
|
-- Standard or priority add
|
20
|
-
|
35
|
+
elseif priority == 0 then
|
21
36
|
rcall("RPUSH", parentTarget, parentId)
|
22
37
|
else
|
23
38
|
addJobWithPriority(parentQueueKey .. ":priority", priority, parentTarget, parentId)
|
@@ -89,7 +89,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
89
89
|
rcall("SREM", KEYS[5], ARGV[1])
|
90
90
|
else
|
91
91
|
if lockToken then
|
92
|
-
rcall("SET", "DEBUG", lockToken)
|
93
92
|
-- Lock exists but token does not match
|
94
93
|
return -6
|
95
94
|
else
|
@@ -129,7 +128,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
129
128
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
130
129
|
updateParentDepsIfNeeded(parentKey, parentQueueKey,
|
131
130
|
dependenciesSet, parentId, jobIdKey,
|
132
|
-
ARGV[4])
|
131
|
+
ARGV[4], timestamp)
|
133
132
|
end
|
134
133
|
elseif opts['fpof'] then
|
135
134
|
moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
|
@@ -35,7 +35,7 @@ export interface DefaultJobOptions {
|
|
35
35
|
lifo?: boolean;
|
36
36
|
/**
|
37
37
|
* If true, removes the job when it successfully completes
|
38
|
-
* When given
|
38
|
+
* When given a number, it specifies the maximum amount of
|
39
39
|
* jobs to keep, or you can provide an object specifying max
|
40
40
|
* age and/or count to keep.
|
41
41
|
* Default behavior is to keep the job in the completed set.
|
@@ -43,7 +43,7 @@ export interface DefaultJobOptions {
|
|
43
43
|
removeOnComplete?: boolean | number | KeepJobs;
|
44
44
|
/**
|
45
45
|
* If true, removes the job when it fails after all attempts.
|
46
|
-
* When given
|
46
|
+
* When given a number, it specifies the maximum amount of
|
47
47
|
* jobs to keep, or you can provide an object specifying max
|
48
48
|
* age and/or count to keep.
|
49
49
|
*/
|
@@ -113,7 +113,7 @@ local jobCounter = rcall("INCR", KEYS[4])
|
|
113
113
|
]]
|
114
114
|
-- Includes
|
115
115
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
116
|
-
parentId, jobIdKey, returnvalue )
|
116
|
+
parentId, jobIdKey, returnvalue, timestamp )
|
117
117
|
local processedSet = parentKey .. ":processed"
|
118
118
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
119
119
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
@@ -121,9 +121,22 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
121
121
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
122
122
|
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait",
|
123
123
|
parentQueueKey .. ":paused")
|
124
|
-
local
|
124
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
125
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
126
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
127
|
+
if delay > 0 then
|
128
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
129
|
+
local score = delayedTimestamp * 0x1000
|
130
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
131
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
132
|
+
if rcall("LLEN", parentTarget) == 0 then
|
133
|
+
local nextTimestamp = getNextDelayedTimestamp(parentDelayedKey)
|
134
|
+
if not nextTimestamp or (delayedTimestamp <= nextTimestamp) then
|
135
|
+
rcall("LPUSH", parentTarget, "0:" .. delayedTimestamp - tonumber(timestamp))
|
136
|
+
end
|
137
|
+
end
|
125
138
|
-- Standard or priority add
|
126
|
-
|
139
|
+
elseif priority == 0 then
|
127
140
|
rcall("RPUSH", parentTarget, parentId)
|
128
141
|
else
|
129
142
|
addJobWithPriority(parentQueueKey .. ":priority", priority, parentTarget, parentId)
|
@@ -134,6 +147,7 @@ end
|
|
134
147
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
135
148
|
trimEvents(KEYS[3], KEYS[8])
|
136
149
|
local parentDependenciesKey = args[7]
|
150
|
+
local timestamp = args[4]
|
137
151
|
if args[2] == "" then
|
138
152
|
jobId = jobCounter
|
139
153
|
jobIdKey = args[1] .. jobId
|
@@ -145,7 +159,7 @@ else
|
|
145
159
|
if rcall("ZSCORE", KEYS[7], jobId) ~= false then
|
146
160
|
local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
|
147
161
|
updateParentDepsIfNeeded(parentKey, parent['queueKey'], parentDependenciesKey,
|
148
|
-
parent['id'], jobIdKey, returnvalue)
|
162
|
+
parent['id'], jobIdKey, returnvalue, timestamp)
|
149
163
|
else
|
150
164
|
if parentDependenciesKey ~= nil then
|
151
165
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
@@ -160,7 +174,6 @@ end
|
|
160
174
|
local jsonOpts = cjson.encode(opts)
|
161
175
|
local delay = opts['delay'] or 0
|
162
176
|
local priority = opts['priority'] or 0
|
163
|
-
local timestamp = args[4]
|
164
177
|
local optionalValues = {}
|
165
178
|
if parentKey ~= nil then
|
166
179
|
table.insert(optionalValues, "parentKey")
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsOf,CAAC;AACW,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -382,7 +382,7 @@ end
|
|
382
382
|
]]
|
383
383
|
-- Includes
|
384
384
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
385
|
-
parentId, jobIdKey, returnvalue )
|
385
|
+
parentId, jobIdKey, returnvalue, timestamp )
|
386
386
|
local processedSet = parentKey .. ":processed"
|
387
387
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
388
388
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
@@ -390,9 +390,22 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
390
390
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
391
391
|
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait",
|
392
392
|
parentQueueKey .. ":paused")
|
393
|
-
local
|
393
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
394
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
395
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
396
|
+
if delay > 0 then
|
397
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
398
|
+
local score = delayedTimestamp * 0x1000
|
399
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
400
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
401
|
+
if rcall("LLEN", parentTarget) == 0 then
|
402
|
+
local nextTimestamp = getNextDelayedTimestamp(parentDelayedKey)
|
403
|
+
if not nextTimestamp or (delayedTimestamp <= nextTimestamp) then
|
404
|
+
rcall("LPUSH", parentTarget, "0:" .. delayedTimestamp - tonumber(timestamp))
|
405
|
+
end
|
406
|
+
end
|
394
407
|
-- Standard or priority add
|
395
|
-
|
408
|
+
elseif priority == 0 then
|
396
409
|
rcall("RPUSH", parentTarget, parentId)
|
397
410
|
else
|
398
411
|
addJobWithPriority(parentQueueKey .. ":priority", priority, parentTarget, parentId)
|
@@ -433,7 +446,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
433
446
|
rcall("SREM", KEYS[5], ARGV[1])
|
434
447
|
else
|
435
448
|
if lockToken then
|
436
|
-
rcall("SET", "DEBUG", lockToken)
|
437
449
|
-- Lock exists but token does not match
|
438
450
|
return -6
|
439
451
|
else
|
@@ -467,7 +479,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
467
479
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
468
480
|
updateParentDepsIfNeeded(parentKey, parentQueueKey,
|
469
481
|
dependenciesSet, parentId, jobIdKey,
|
470
|
-
ARGV[4])
|
482
|
+
ARGV[4], timestamp)
|
471
483
|
end
|
472
484
|
elseif opts['fpof'] then
|
473
485
|
moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0iBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -79,6 +79,7 @@ local jobCounter = rcall("INCR", KEYS[4])
|
|
79
79
|
trimEvents(KEYS[3], KEYS[8])
|
80
80
|
|
81
81
|
local parentDependenciesKey = args[7]
|
82
|
+
local timestamp = args[4]
|
82
83
|
if args[2] == "" then
|
83
84
|
jobId = jobCounter
|
84
85
|
jobIdKey = args[1] .. jobId
|
@@ -90,7 +91,7 @@ else
|
|
90
91
|
if rcall("ZSCORE", KEYS[7], jobId) ~= false then
|
91
92
|
local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
|
92
93
|
updateParentDepsIfNeeded(parentKey, parent['queueKey'], parentDependenciesKey,
|
93
|
-
parent['id'], jobIdKey, returnvalue)
|
94
|
+
parent['id'], jobIdKey, returnvalue, timestamp)
|
94
95
|
else
|
95
96
|
if parentDependenciesKey ~= nil then
|
96
97
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
@@ -106,7 +107,6 @@ end
|
|
106
107
|
local jsonOpts = cjson.encode(opts)
|
107
108
|
local delay = opts['delay'] or 0
|
108
109
|
local priority = opts['priority'] or 0
|
109
|
-
local timestamp = args[4]
|
110
110
|
|
111
111
|
local optionalValues = {}
|
112
112
|
if parentKey ~= nil then
|
@@ -4,10 +4,11 @@
|
|
4
4
|
|
5
5
|
-- Includes
|
6
6
|
--- @include "addJobWithPriority"
|
7
|
+
--- @include "getNextDelayedTimestamp"
|
7
8
|
--- @include "getTargetQueueList"
|
8
9
|
|
9
10
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
10
|
-
parentId, jobIdKey, returnvalue )
|
11
|
+
parentId, jobIdKey, returnvalue, timestamp )
|
11
12
|
local processedSet = parentKey .. ":processed"
|
12
13
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
13
14
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
@@ -15,9 +16,23 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
15
16
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
16
17
|
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait",
|
17
18
|
parentQueueKey .. ":paused")
|
18
|
-
local
|
19
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
20
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
21
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
22
|
+
if delay > 0 then
|
23
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
24
|
+
local score = delayedTimestamp * 0x1000
|
25
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
26
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
27
|
+
|
28
|
+
if rcall("LLEN", parentTarget) == 0 then
|
29
|
+
local nextTimestamp = getNextDelayedTimestamp(parentDelayedKey)
|
30
|
+
if not nextTimestamp or (delayedTimestamp <= nextTimestamp) then
|
31
|
+
rcall("LPUSH", parentTarget, "0:" .. delayedTimestamp - tonumber(timestamp))
|
32
|
+
end
|
33
|
+
end
|
19
34
|
-- Standard or priority add
|
20
|
-
|
35
|
+
elseif priority == 0 then
|
21
36
|
rcall("RPUSH", parentTarget, parentId)
|
22
37
|
else
|
23
38
|
addJobWithPriority(parentQueueKey .. ":priority", priority, parentTarget, parentId)
|
@@ -89,7 +89,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
89
89
|
rcall("SREM", KEYS[5], ARGV[1])
|
90
90
|
else
|
91
91
|
if lockToken then
|
92
|
-
rcall("SET", "DEBUG", lockToken)
|
93
92
|
-- Lock exists but token does not match
|
94
93
|
return -6
|
95
94
|
else
|
@@ -129,7 +128,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
129
128
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
130
129
|
updateParentDepsIfNeeded(parentKey, parentQueueKey,
|
131
130
|
dependenciesSet, parentId, jobIdKey,
|
132
|
-
ARGV[4])
|
131
|
+
ARGV[4], timestamp)
|
133
132
|
end
|
134
133
|
elseif opts['fpof'] then
|
135
134
|
moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
|
@@ -35,7 +35,7 @@ export interface DefaultJobOptions {
|
|
35
35
|
lifo?: boolean;
|
36
36
|
/**
|
37
37
|
* If true, removes the job when it successfully completes
|
38
|
-
* When given
|
38
|
+
* When given a number, it specifies the maximum amount of
|
39
39
|
* jobs to keep, or you can provide an object specifying max
|
40
40
|
* age and/or count to keep.
|
41
41
|
* Default behavior is to keep the job in the completed set.
|
@@ -43,7 +43,7 @@ export interface DefaultJobOptions {
|
|
43
43
|
removeOnComplete?: boolean | number | KeepJobs;
|
44
44
|
/**
|
45
45
|
* If true, removes the job when it fails after all attempts.
|
46
|
-
* When given
|
46
|
+
* When given a number, it specifies the maximum amount of
|
47
47
|
* jobs to keep, or you can provide an object specifying max
|
48
48
|
* age and/or count to keep.
|
49
49
|
*/
|
@@ -110,7 +110,7 @@ local jobCounter = rcall("INCR", KEYS[4])
|
|
110
110
|
]]
|
111
111
|
-- Includes
|
112
112
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
113
|
-
parentId, jobIdKey, returnvalue )
|
113
|
+
parentId, jobIdKey, returnvalue, timestamp )
|
114
114
|
local processedSet = parentKey .. ":processed"
|
115
115
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
116
116
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
@@ -118,9 +118,22 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
118
118
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
119
119
|
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait",
|
120
120
|
parentQueueKey .. ":paused")
|
121
|
-
local
|
121
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
122
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
123
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
124
|
+
if delay > 0 then
|
125
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
126
|
+
local score = delayedTimestamp * 0x1000
|
127
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
128
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
129
|
+
if rcall("LLEN", parentTarget) == 0 then
|
130
|
+
local nextTimestamp = getNextDelayedTimestamp(parentDelayedKey)
|
131
|
+
if not nextTimestamp or (delayedTimestamp <= nextTimestamp) then
|
132
|
+
rcall("LPUSH", parentTarget, "0:" .. delayedTimestamp - tonumber(timestamp))
|
133
|
+
end
|
134
|
+
end
|
122
135
|
-- Standard or priority add
|
123
|
-
|
136
|
+
elseif priority == 0 then
|
124
137
|
rcall("RPUSH", parentTarget, parentId)
|
125
138
|
else
|
126
139
|
addJobWithPriority(parentQueueKey .. ":priority", priority, parentTarget, parentId)
|
@@ -131,6 +144,7 @@ end
|
|
131
144
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
132
145
|
trimEvents(KEYS[3], KEYS[8])
|
133
146
|
local parentDependenciesKey = args[7]
|
147
|
+
local timestamp = args[4]
|
134
148
|
if args[2] == "" then
|
135
149
|
jobId = jobCounter
|
136
150
|
jobIdKey = args[1] .. jobId
|
@@ -142,7 +156,7 @@ else
|
|
142
156
|
if rcall("ZSCORE", KEYS[7], jobId) ~= false then
|
143
157
|
local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
|
144
158
|
updateParentDepsIfNeeded(parentKey, parent['queueKey'], parentDependenciesKey,
|
145
|
-
parent['id'], jobIdKey, returnvalue)
|
159
|
+
parent['id'], jobIdKey, returnvalue, timestamp)
|
146
160
|
else
|
147
161
|
if parentDependenciesKey ~= nil then
|
148
162
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
@@ -157,7 +171,6 @@ end
|
|
157
171
|
local jsonOpts = cjson.encode(opts)
|
158
172
|
local delay = opts['delay'] or 0
|
159
173
|
local priority = opts['priority'] or 0
|
160
|
-
local timestamp = args[4]
|
161
174
|
local optionalValues = {}
|
162
175
|
if parentKey ~= nil then
|
163
176
|
table.insert(optionalValues, "parentKey")
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsOf,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -379,7 +379,7 @@ end
|
|
379
379
|
]]
|
380
380
|
-- Includes
|
381
381
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
382
|
-
parentId, jobIdKey, returnvalue )
|
382
|
+
parentId, jobIdKey, returnvalue, timestamp )
|
383
383
|
local processedSet = parentKey .. ":processed"
|
384
384
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
385
385
|
local activeParent = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
|
@@ -387,9 +387,22 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
387
387
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
388
388
|
local parentTarget = getTargetQueueList(parentQueueKey .. ":meta", parentQueueKey .. ":wait",
|
389
389
|
parentQueueKey .. ":paused")
|
390
|
-
local
|
390
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
391
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
392
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
393
|
+
if delay > 0 then
|
394
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
395
|
+
local score = delayedTimestamp * 0x1000
|
396
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
397
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
398
|
+
if rcall("LLEN", parentTarget) == 0 then
|
399
|
+
local nextTimestamp = getNextDelayedTimestamp(parentDelayedKey)
|
400
|
+
if not nextTimestamp or (delayedTimestamp <= nextTimestamp) then
|
401
|
+
rcall("LPUSH", parentTarget, "0:" .. delayedTimestamp - tonumber(timestamp))
|
402
|
+
end
|
403
|
+
end
|
391
404
|
-- Standard or priority add
|
392
|
-
|
405
|
+
elseif priority == 0 then
|
393
406
|
rcall("RPUSH", parentTarget, parentId)
|
394
407
|
else
|
395
408
|
addJobWithPriority(parentQueueKey .. ":priority", priority, parentTarget, parentId)
|
@@ -430,7 +443,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
430
443
|
rcall("SREM", KEYS[5], ARGV[1])
|
431
444
|
else
|
432
445
|
if lockToken then
|
433
|
-
rcall("SET", "DEBUG", lockToken)
|
434
446
|
-- Lock exists but token does not match
|
435
447
|
return -6
|
436
448
|
else
|
@@ -464,7 +476,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
464
476
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
465
477
|
updateParentDepsIfNeeded(parentKey, parentQueueKey,
|
466
478
|
dependenciesSet, parentId, jobIdKey,
|
467
|
-
ARGV[4])
|
479
|
+
ARGV[4], timestamp)
|
468
480
|
end
|
469
481
|
elseif opts['fpof'] then
|
470
482
|
moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0iBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|