bullmq 5.3.2 → 5.4.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.
Files changed (56) hide show
  1. package/README.md +13 -0
  2. package/dist/cjs/classes/job.js +20 -1
  3. package/dist/cjs/classes/job.js.map +1 -1
  4. package/dist/cjs/classes/scripts.js +83 -13
  5. package/dist/cjs/classes/scripts.js.map +1 -1
  6. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +3 -0
  7. package/dist/cjs/commands/removeChildDependency-1.lua +34 -0
  8. package/dist/cjs/commands/script-loader.js +15 -7
  9. package/dist/cjs/commands/script-loader.js.map +1 -1
  10. package/dist/cjs/scripts/cleanJobsInSet-2.js +3 -0
  11. package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
  12. package/dist/cjs/scripts/drain-4.js +3 -0
  13. package/dist/cjs/scripts/drain-4.js.map +1 -1
  14. package/dist/cjs/scripts/index.js +1 -0
  15. package/dist/cjs/scripts/index.js.map +1 -1
  16. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +3 -0
  17. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  18. package/dist/cjs/scripts/moveToFinished-14.js +3 -0
  19. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  20. package/dist/cjs/scripts/obliterate-2.js +3 -0
  21. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  22. package/dist/cjs/scripts/removeChildDependency-1.js +149 -0
  23. package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -0
  24. package/dist/cjs/scripts/removeJob-1.js +3 -0
  25. package/dist/cjs/scripts/removeJob-1.js.map +1 -1
  26. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  27. package/dist/esm/classes/job.d.ts +7 -1
  28. package/dist/esm/classes/job.js +20 -1
  29. package/dist/esm/classes/job.js.map +1 -1
  30. package/dist/esm/classes/scripts.d.ts +9 -1
  31. package/dist/esm/classes/scripts.js +83 -13
  32. package/dist/esm/classes/scripts.js.map +1 -1
  33. package/dist/esm/commands/includes/removeParentDependencyKey.lua +3 -0
  34. package/dist/esm/commands/removeChildDependency-1.lua +34 -0
  35. package/dist/esm/commands/script-loader.js +15 -7
  36. package/dist/esm/commands/script-loader.js.map +1 -1
  37. package/dist/esm/scripts/cleanJobsInSet-2.js +3 -0
  38. package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
  39. package/dist/esm/scripts/drain-4.js +3 -0
  40. package/dist/esm/scripts/drain-4.js.map +1 -1
  41. package/dist/esm/scripts/index.d.ts +1 -0
  42. package/dist/esm/scripts/index.js +1 -0
  43. package/dist/esm/scripts/index.js.map +1 -1
  44. package/dist/esm/scripts/moveStalledJobsToWait-9.js +3 -0
  45. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  46. package/dist/esm/scripts/moveToFinished-14.js +3 -0
  47. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  48. package/dist/esm/scripts/obliterate-2.js +3 -0
  49. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  50. package/dist/esm/scripts/removeChildDependency-1.d.ts +5 -0
  51. package/dist/esm/scripts/removeChildDependency-1.js +146 -0
  52. package/dist/esm/scripts/removeChildDependency-1.js.map +1 -0
  53. package/dist/esm/scripts/removeJob-1.js +3 -0
  54. package/dist/esm/scripts/removeJob-1.js.map +1 -1
  55. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +3 -2
@@ -132,6 +132,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
132
132
  end
133
133
  end
134
134
  end
135
+ return true
135
136
  end
136
137
  else
137
138
  local missedParentKey = rcall("HGET", jobKey, "parentKey")
@@ -158,9 +159,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
158
159
  end
159
160
  end
160
161
  end
162
+ return true
161
163
  end
162
164
  end
163
165
  end
166
+ return false
164
167
  end
165
168
  local function removeJob(jobId, hard, baseKey)
166
169
  local jobKey = baseKey .. jobId
@@ -1 +1 @@
1
- {"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Rf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiSf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -107,6 +107,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
107
107
  end
108
108
  end
109
109
  end
110
+ return true
110
111
  end
111
112
  else
112
113
  local missedParentKey = rcall("HGET", jobKey, "parentKey")
@@ -133,9 +134,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
133
134
  end
134
135
  end
135
136
  end
137
+ return true
136
138
  end
137
139
  end
138
140
  end
141
+ return false
139
142
  end
140
143
  local function removeJob(jobId, hard, baseKey)
141
144
  local jobKey = baseKey .. jobId
@@ -1 +1 @@
1
- {"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmMf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsMf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -28,6 +28,7 @@ tslib_1.__exportStar(require("./paginate-1"), exports);
28
28
  tslib_1.__exportStar(require("./pause-7"), exports);
29
29
  tslib_1.__exportStar(require("./promote-8"), exports);
30
30
  tslib_1.__exportStar(require("./releaseLock-1"), exports);
31
+ tslib_1.__exportStar(require("./removeChildDependency-1"), exports);
31
32
  tslib_1.__exportStar(require("./removeJob-1"), exports);
32
33
  tslib_1.__exportStar(require("./removeRepeatable-2"), exports);
33
34
  tslib_1.__exportStar(require("./reprocessJob-7"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,0DAAgC;AAChC,6DAAmC;AACnC,6DAAmC;AACnC,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,wDAA8B;AAC9B,uDAA6B;AAC7B,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,uEAA6C;AAC7C,6DAAmC;AACnC,oEAA0C;AAC1C,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,oEAA0C;AAC1C,yDAA+B;AAC/B,uDAA6B;AAC7B,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,wDAA8B;AAC9B,+DAAqC;AACrC,2DAAiC;AACjC,wDAA8B;AAC9B,6DAAmC;AACnC,yDAA+B;AAC/B,6DAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,0DAAgC;AAChC,6DAAmC;AACnC,6DAAmC;AACnC,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,wDAA8B;AAC9B,uDAA6B;AAC7B,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,uEAA6C;AAC7C,6DAAmC;AACnC,oEAA0C;AAC1C,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,oEAA0C;AAC1C,yDAA+B;AAC/B,uDAA6B;AAC7B,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,oEAA0C;AAC1C,wDAA8B;AAC9B,+DAAqC;AACrC,2DAAiC;AACjC,wDAA8B;AAC9B,6DAAmC;AACnC,yDAA+B;AAC/B,6DAAmC"}
@@ -124,6 +124,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
124
124
  end
125
125
  end
126
126
  end
127
+ return true
127
128
  end
128
129
  else
129
130
  local missedParentKey = rcall("HGET", jobKey, "parentKey")
@@ -150,9 +151,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
150
151
  end
151
152
  end
152
153
  end
154
+ return true
153
155
  end
154
156
  end
155
157
  end
158
+ return false
156
159
  end
157
160
  local function removeJob(jobId, hard, baseKey)
158
161
  local jobKey = baseKey .. jobId
@@ -1 +1 @@
1
- {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA8SS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAiTS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -402,6 +402,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
402
402
  end
403
403
  end
404
404
  end
405
+ return true
405
406
  end
406
407
  else
407
408
  local missedParentKey = rcall("HGET", jobKey, "parentKey")
@@ -428,9 +429,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
428
429
  end
429
430
  end
430
431
  end
432
+ return true
431
433
  end
432
434
  end
433
435
  end
436
+ return false
434
437
  end
435
438
  local function removeJob(jobId, hard, baseKey)
436
439
  local jobKey = baseKey .. jobId
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4pBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+pBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -109,6 +109,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
109
109
  end
110
110
  end
111
111
  end
112
+ return true
112
113
  end
113
114
  else
114
115
  local missedParentKey = rcall("HGET", jobKey, "parentKey")
@@ -135,9 +136,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
135
136
  end
136
137
  end
137
138
  end
139
+ return true
138
140
  end
139
141
  end
140
142
  end
143
+ return false
141
144
  end
142
145
  local function removeJob(jobId, hard, baseKey)
143
146
  local jobKey = baseKey .. jobId
@@ -1 +1 @@
1
- {"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqQf,CAAC;AACW,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwQf,CAAC;AACW,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeChildDependency = void 0;
4
+ const content = `--[[
5
+ Break parent-child dependency by removing
6
+ child reference from parent
7
+ Input:
8
+ KEYS[1] 'key' prefix,
9
+ ARGV[1] job key
10
+ ARGV[2] parent key
11
+ Output:
12
+ 0 - OK
13
+ 1 - There is not relationship.
14
+ -1 - Missing job key
15
+ -5 - Missing parent key
16
+ ]]
17
+ local rcall = redis.call
18
+ local jobKey = ARGV[1]
19
+ local parentKey = ARGV[2]
20
+ -- Includes
21
+ --[[
22
+ Check if this job has a parent. If so we will just remove it from
23
+ the parent child list, but if it is the last child we should move the parent to "wait/paused"
24
+ which requires code from "moveToFinished"
25
+ ]]
26
+ -- Includes
27
+ --[[
28
+ Function to add job in target list and add marker if needed.
29
+ ]]
30
+ -- Includes
31
+ --[[
32
+ Add marker if needed when a job is available.
33
+ ]]
34
+ local function addBaseMarkerIfNeeded(markerKey, isPaused)
35
+ if not isPaused then
36
+ rcall("ZADD", markerKey, 0, "0")
37
+ end
38
+ end
39
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
40
+ rcall(pushCmd, targetKey, jobId)
41
+ addBaseMarkerIfNeeded(markerKey, isPaused)
42
+ end
43
+ --[[
44
+ Functions to destructure job key.
45
+ Just a bit of warning, these functions may be a bit slow and affect performance significantly.
46
+ ]]
47
+ local getJobIdFromKey = function (jobKey)
48
+ return string.match(jobKey, ".*:(.*)")
49
+ end
50
+ local getJobKeyPrefix = function (jobKey, jobId)
51
+ return string.sub(jobKey, 0, #jobKey - #jobId)
52
+ end
53
+ --[[
54
+ Function to check for the meta.paused key to decide if we are paused or not
55
+ (since an empty list and !EXISTS are not really the same).
56
+ ]]
57
+ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
58
+ if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
59
+ return waitKey, false
60
+ else
61
+ return pausedKey, true
62
+ end
63
+ end
64
+ --[[
65
+ Function to remove job keys.
66
+ ]]
67
+ local function removeJobKeys(jobKey)
68
+ return rcall("DEL", jobKey, jobKey .. ':logs',
69
+ jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
70
+ end
71
+ local function moveParentToWait(parentPrefix, parentId, emitEvent)
72
+ local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
73
+ parentPrefix .. "paused")
74
+ addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
75
+ if emitEvent then
76
+ local parentEventStream = parentPrefix .. "events"
77
+ rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
78
+ end
79
+ end
80
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
81
+ if parentKey then
82
+ local parentDependenciesKey = parentKey .. ":dependencies"
83
+ local result = rcall("SREM", parentDependenciesKey, jobKey)
84
+ if result > 0 then
85
+ local pendingDependencies = rcall("SCARD", parentDependenciesKey)
86
+ if pendingDependencies == 0 then
87
+ local parentId = getJobIdFromKey(parentKey)
88
+ local parentPrefix = getJobKeyPrefix(parentKey, parentId)
89
+ local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
90
+ if numRemovedElements == 1 then
91
+ if hard then -- remove parent in same queue
92
+ if parentPrefix == baseKey then
93
+ removeParentDependencyKey(parentKey, hard, nil, baseKey)
94
+ removeJobKeys(parentKey)
95
+ else
96
+ moveParentToWait(parentPrefix, parentId)
97
+ end
98
+ else
99
+ moveParentToWait(parentPrefix, parentId, true)
100
+ end
101
+ end
102
+ end
103
+ return true
104
+ end
105
+ else
106
+ local missedParentKey = rcall("HGET", jobKey, "parentKey")
107
+ if( (type(missedParentKey) == "string") and missedParentKey ~= ""
108
+ and (rcall("EXISTS", missedParentKey) == 1)) then
109
+ local parentDependenciesKey = missedParentKey .. ":dependencies"
110
+ local result = rcall("SREM", parentDependenciesKey, jobKey)
111
+ if result > 0 then
112
+ local pendingDependencies = rcall("SCARD", parentDependenciesKey)
113
+ if pendingDependencies == 0 then
114
+ local parentId = getJobIdFromKey(missedParentKey)
115
+ local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
116
+ local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
117
+ if numRemovedElements == 1 then
118
+ if hard then
119
+ if parentPrefix == baseKey then
120
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
121
+ removeJobKeys(missedParentKey)
122
+ else
123
+ moveParentToWait(parentPrefix, parentId)
124
+ end
125
+ else
126
+ moveParentToWait(parentPrefix, parentId, true)
127
+ end
128
+ end
129
+ end
130
+ return true
131
+ end
132
+ end
133
+ end
134
+ return false
135
+ end
136
+ if rcall("EXISTS", jobKey) ~= 1 then return -1 end
137
+ if rcall("EXISTS", parentKey) ~= 1 then return -5 end
138
+ if removeParentDependencyKey(jobKey, false, parentKey, KEYS[1]) then
139
+ rcall("HDEL", jobKey, "parentKey", "parent")
140
+ return 0
141
+ else
142
+ return 1
143
+ end`;
144
+ exports.removeChildDependency = {
145
+ name: 'removeChildDependency',
146
+ content,
147
+ keys: 1,
148
+ };
149
+ //# sourceMappingURL=removeChildDependency-1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeChildDependency-1.js","sourceRoot":"","sources":["../../../src/scripts/removeChildDependency-1.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2IZ,CAAC;AACQ,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -168,6 +168,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
168
168
  end
169
169
  end
170
170
  end
171
+ return true
171
172
  end
172
173
  else
173
174
  local missedParentKey = rcall("HGET", jobKey, "parentKey")
@@ -194,9 +195,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
194
195
  end
195
196
  end
196
197
  end
198
+ return true
197
199
  end
198
200
  end
199
201
  end
202
+ return false
200
203
  end
201
204
  local function removeJob( prefix, jobId, parentKey, removeChildren)
202
205
  local jobKey = prefix .. jobId;
@@ -1 +1 @@
1
- {"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoPf,CAAC;AACW,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeJob-1.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-1.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuPf,CAAC;AACW,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}