bullmq 5.44.1 → 5.52.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 (204) hide show
  1. package/dist/cjs/classes/async-fifo-queue.js.map +1 -1
  2. package/dist/cjs/classes/child-processor.js.map +1 -1
  3. package/dist/cjs/classes/child.js.map +1 -1
  4. package/dist/cjs/classes/flow-producer.js +15 -4
  5. package/dist/cjs/classes/flow-producer.js.map +1 -1
  6. package/dist/cjs/classes/job-scheduler.js +1 -1
  7. package/dist/cjs/classes/job-scheduler.js.map +1 -1
  8. package/dist/cjs/classes/job.js +137 -54
  9. package/dist/cjs/classes/job.js.map +1 -1
  10. package/dist/cjs/classes/queue-base.js +1 -4
  11. package/dist/cjs/classes/queue-base.js.map +1 -1
  12. package/dist/cjs/classes/queue-events-producer.js.map +1 -1
  13. package/dist/cjs/classes/queue-events.js.map +1 -1
  14. package/dist/cjs/classes/queue-getters.js +12 -15
  15. package/dist/cjs/classes/queue-getters.js.map +1 -1
  16. package/dist/cjs/classes/queue-keys.js.map +1 -1
  17. package/dist/cjs/classes/queue.js +12 -13
  18. package/dist/cjs/classes/queue.js.map +1 -1
  19. package/dist/cjs/classes/redis-connection.js +1 -1
  20. package/dist/cjs/classes/redis-connection.js.map +1 -1
  21. package/dist/cjs/classes/repeat.js +1 -1
  22. package/dist/cjs/classes/repeat.js.map +1 -1
  23. package/dist/cjs/classes/scripts.js +18 -7
  24. package/dist/cjs/classes/scripts.js.map +1 -1
  25. package/dist/cjs/classes/worker.js +4 -0
  26. package/dist/cjs/classes/worker.js.map +1 -1
  27. package/dist/cjs/commands/addJobScheduler-11.lua +52 -33
  28. package/dist/cjs/commands/includes/deduplicateJob.lua +16 -17
  29. package/dist/cjs/commands/includes/isLocked.lua +1 -0
  30. package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +79 -0
  31. package/dist/cjs/commands/includes/moveParentToWait.lua +48 -0
  32. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  33. package/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  34. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  35. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  36. package/dist/cjs/commands/includes/removeJob.lua +2 -2
  37. package/dist/cjs/commands/includes/removeJobWithChildren.lua +94 -0
  38. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +5 -5
  39. package/dist/cjs/commands/includes/storeJob.lua +1 -1
  40. package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  41. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +18 -53
  42. package/dist/cjs/commands/moveToFinished-14.lua +43 -51
  43. package/dist/cjs/commands/moveToWaitingChildren-8.lua +5 -32
  44. package/dist/cjs/commands/removeJob-3.lua +14 -72
  45. package/dist/cjs/commands/removeUnprocessedChildren-2.lua +31 -0
  46. package/dist/cjs/commands/updateJobScheduler-12.lua +29 -23
  47. package/dist/cjs/scripts/addDelayedJob-6.js +73 -55
  48. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  49. package/dist/cjs/scripts/addJobScheduler-11.js +59 -40
  50. package/dist/cjs/scripts/addJobScheduler-11.js.map +1 -1
  51. package/dist/cjs/scripts/addParentJob-4.js +73 -55
  52. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  53. package/dist/cjs/scripts/addPrioritizedJob-8.js +73 -55
  54. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
  55. package/dist/cjs/scripts/addRepeatableJob-2.js +14 -9
  56. package/dist/cjs/scripts/addRepeatableJob-2.js.map +1 -1
  57. package/dist/cjs/scripts/addStandardJob-8.js +73 -55
  58. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
  59. package/dist/cjs/scripts/cleanJobsInSet-3.js +14 -9
  60. package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
  61. package/dist/cjs/scripts/drain-5.js +14 -9
  62. package/dist/cjs/scripts/drain-5.js.map +1 -1
  63. package/dist/cjs/scripts/index.js +1 -0
  64. package/dist/cjs/scripts/index.js.map +1 -1
  65. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +157 -155
  66. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  67. package/dist/cjs/scripts/moveToFinished-14.js +183 -157
  68. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  69. package/dist/cjs/scripts/moveToWaitingChildren-8.js +145 -137
  70. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
  71. package/dist/cjs/scripts/obliterate-2.js +14 -9
  72. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  73. package/dist/cjs/scripts/removeChildDependency-1.js +5 -5
  74. package/dist/cjs/scripts/removeJob-3.js +97 -63
  75. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  76. package/dist/cjs/scripts/removeUnprocessedChildren-2.js +338 -0
  77. package/dist/cjs/scripts/removeUnprocessedChildren-2.js.map +1 -0
  78. package/dist/cjs/scripts/updateJobScheduler-12.js +27 -21
  79. package/dist/cjs/scripts/updateJobScheduler-12.js.map +1 -1
  80. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  81. package/dist/cjs/types/index.js +1 -0
  82. package/dist/cjs/types/index.js.map +1 -1
  83. package/dist/cjs/types/job-progress.js +3 -0
  84. package/dist/cjs/types/job-progress.js.map +1 -0
  85. package/dist/cjs/utils.js +12 -1
  86. package/dist/cjs/utils.js.map +1 -1
  87. package/dist/cjs/version.js +1 -1
  88. package/dist/esm/classes/async-fifo-queue.js.map +1 -1
  89. package/dist/esm/classes/child-processor.js.map +1 -1
  90. package/dist/esm/classes/child.js.map +1 -1
  91. package/dist/esm/classes/flow-producer.js +15 -4
  92. package/dist/esm/classes/flow-producer.js.map +1 -1
  93. package/dist/esm/classes/job-scheduler.js +1 -1
  94. package/dist/esm/classes/job-scheduler.js.map +1 -1
  95. package/dist/esm/classes/job.d.ts +49 -14
  96. package/dist/esm/classes/job.js +138 -55
  97. package/dist/esm/classes/job.js.map +1 -1
  98. package/dist/esm/classes/queue-base.d.ts +1 -4
  99. package/dist/esm/classes/queue-base.js +1 -4
  100. package/dist/esm/classes/queue-base.js.map +1 -1
  101. package/dist/esm/classes/queue-events-producer.d.ts +2 -2
  102. package/dist/esm/classes/queue-events-producer.js.map +1 -1
  103. package/dist/esm/classes/queue-events.d.ts +118 -29
  104. package/dist/esm/classes/queue-events.js.map +1 -1
  105. package/dist/esm/classes/queue-getters.d.ts +11 -14
  106. package/dist/esm/classes/queue-getters.js +12 -15
  107. package/dist/esm/classes/queue-getters.js.map +1 -1
  108. package/dist/esm/classes/queue-keys.js.map +1 -1
  109. package/dist/esm/classes/queue.d.ts +14 -15
  110. package/dist/esm/classes/queue.js +12 -13
  111. package/dist/esm/classes/queue.js.map +1 -1
  112. package/dist/esm/classes/redis-connection.js +1 -1
  113. package/dist/esm/classes/redis-connection.js.map +1 -1
  114. package/dist/esm/classes/repeat.js +1 -1
  115. package/dist/esm/classes/repeat.js.map +1 -1
  116. package/dist/esm/classes/scripts.d.ts +4 -3
  117. package/dist/esm/classes/scripts.js +18 -7
  118. package/dist/esm/classes/scripts.js.map +1 -1
  119. package/dist/esm/classes/worker.d.ts +2 -1
  120. package/dist/esm/classes/worker.js +5 -1
  121. package/dist/esm/classes/worker.js.map +1 -1
  122. package/dist/esm/commands/addJobScheduler-11.lua +52 -33
  123. package/dist/esm/commands/includes/deduplicateJob.lua +16 -17
  124. package/dist/esm/commands/includes/isLocked.lua +1 -0
  125. package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +79 -0
  126. package/dist/esm/commands/includes/moveParentToWait.lua +48 -0
  127. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  128. package/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  129. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  130. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  131. package/dist/esm/commands/includes/removeJob.lua +2 -2
  132. package/dist/esm/commands/includes/removeJobWithChildren.lua +94 -0
  133. package/dist/esm/commands/includes/removeParentDependencyKey.lua +5 -5
  134. package/dist/esm/commands/includes/storeJob.lua +1 -1
  135. package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  136. package/dist/esm/commands/moveStalledJobsToWait-9.lua +18 -53
  137. package/dist/esm/commands/moveToFinished-14.lua +43 -51
  138. package/dist/esm/commands/moveToWaitingChildren-8.lua +5 -32
  139. package/dist/esm/commands/removeJob-3.lua +14 -72
  140. package/dist/esm/commands/removeUnprocessedChildren-2.lua +31 -0
  141. package/dist/esm/commands/updateJobScheduler-12.lua +29 -23
  142. package/dist/esm/interfaces/job-json.d.ts +5 -2
  143. package/dist/esm/interfaces/minimal-job.d.ts +29 -11
  144. package/dist/esm/interfaces/queue-options.d.ts +6 -2
  145. package/dist/esm/interfaces/repeat-options.d.ts +1 -1
  146. package/dist/esm/interfaces/sandboxed-job.d.ts +2 -2
  147. package/dist/esm/interfaces/sandboxed-options.d.ts +1 -1
  148. package/dist/esm/interfaces/telemetry.d.ts +18 -15
  149. package/dist/esm/interfaces/worker-options.d.ts +10 -10
  150. package/dist/esm/scripts/addDelayedJob-6.js +73 -55
  151. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  152. package/dist/esm/scripts/addJobScheduler-11.js +59 -40
  153. package/dist/esm/scripts/addJobScheduler-11.js.map +1 -1
  154. package/dist/esm/scripts/addParentJob-4.js +73 -55
  155. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  156. package/dist/esm/scripts/addPrioritizedJob-8.js +73 -55
  157. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
  158. package/dist/esm/scripts/addRepeatableJob-2.js +14 -9
  159. package/dist/esm/scripts/addRepeatableJob-2.js.map +1 -1
  160. package/dist/esm/scripts/addStandardJob-8.js +73 -55
  161. package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
  162. package/dist/esm/scripts/cleanJobsInSet-3.js +14 -9
  163. package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
  164. package/dist/esm/scripts/drain-5.js +14 -9
  165. package/dist/esm/scripts/drain-5.js.map +1 -1
  166. package/dist/esm/scripts/index.d.ts +1 -0
  167. package/dist/esm/scripts/index.js +1 -0
  168. package/dist/esm/scripts/index.js.map +1 -1
  169. package/dist/esm/scripts/moveStalledJobsToWait-9.js +157 -155
  170. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  171. package/dist/esm/scripts/moveToFinished-14.js +183 -157
  172. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  173. package/dist/esm/scripts/moveToWaitingChildren-8.js +145 -137
  174. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
  175. package/dist/esm/scripts/obliterate-2.js +14 -9
  176. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  177. package/dist/esm/scripts/removeChildDependency-1.js +5 -5
  178. package/dist/esm/scripts/removeJob-3.js +97 -63
  179. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  180. package/dist/esm/scripts/removeUnprocessedChildren-2.d.ts +5 -0
  181. package/dist/esm/scripts/removeUnprocessedChildren-2.js +335 -0
  182. package/dist/esm/scripts/removeUnprocessedChildren-2.js.map +1 -0
  183. package/dist/esm/scripts/updateJobScheduler-12.js +27 -21
  184. package/dist/esm/scripts/updateJobScheduler-12.js.map +1 -1
  185. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  186. package/dist/esm/types/index.d.ts +1 -0
  187. package/dist/esm/types/index.js +1 -0
  188. package/dist/esm/types/index.js.map +1 -1
  189. package/dist/esm/types/job-options.d.ts +13 -2
  190. package/dist/esm/types/job-progress.d.ts +1 -0
  191. package/dist/esm/types/job-progress.js +2 -0
  192. package/dist/esm/types/job-progress.js.map +1 -0
  193. package/dist/esm/utils.d.ts +17 -0
  194. package/dist/esm/utils.js +11 -0
  195. package/dist/esm/utils.js.map +1 -1
  196. package/dist/esm/version.d.ts +1 -1
  197. package/dist/esm/version.js +1 -1
  198. package/package.json +26 -21
  199. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -80
  200. package/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
  201. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  202. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -80
  203. package/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
  204. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
@@ -36,13 +36,12 @@ local timestamp = ARGV[3]
36
36
  local jobId = ARGV[4]
37
37
 
38
38
  --- Includes
39
- --- @include "includes/moveParentFromWaitingChildrenToFailed"
40
- --- @include "includes/moveParentToWaitIfNeeded"
41
- --- @include "includes/removeDeduplicationKeyIfNeeded"
39
+ --- @include "includes/moveChildFromDependenciesIfNeeded"
40
+ --- @include "includes/removeDeduplicationKeyIfNeededOnFinalization"
42
41
  --- @include "includes/removeJobsOnFail"
43
42
  --- @include "includes/removeLock"
44
43
 
45
- local function moveToWaitingChildren (activeKey, waitingChildrenKey, jobId,
44
+ local function moveToWaitingChildren(activeKey, waitingChildrenKey, jobId,
46
45
  timestamp)
47
46
  local score = tonumber(timestamp)
48
47
 
@@ -62,7 +61,7 @@ if rcall("EXISTS", jobKey) == 1 then
62
61
  -- TODO: refactor this logic in an include later
63
62
  local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")
64
63
 
65
- removeDeduplicationKeyIfNeeded(ARGV[5], jobAttributes[2])
64
+ removeDeduplicationKeyIfNeededOnFinalization(ARGV[5], jobAttributes[2], jobId)
66
65
 
67
66
  local failedReason = "children are failed"
68
67
  rcall("ZADD", failedKey, timestamp, jobId)
@@ -74,33 +73,7 @@ if rcall("EXISTS", jobKey) == 1 then
74
73
  local rawOpts = jobAttributes[3]
75
74
  local opts = cjson.decode(rawOpts)
76
75
 
77
- if rawParentData ~= false then
78
- if opts['fpof'] then
79
- local parentData = cjson.decode(rawParentData)
80
- local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
81
- local parentUnsuccesssful = parentKey .. ":unsuccessful"
82
- rcall("ZADD", parentUnsuccesssful, timestamp, jobKey)
83
- moveParentFromWaitingChildrenToFailed(
84
- parentData['queueKey'],
85
- parentData['queueKey'] .. ':' .. parentData['id'],
86
- parentData['id'],
87
- jobKey,
88
- timestamp
89
- )
90
- elseif opts['idof'] or opts['rdof'] then
91
- local parentData = cjson.decode(rawParentData)
92
- local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
93
- local dependenciesSet = parentKey .. ":dependencies"
94
- if rcall("SREM", dependenciesSet, jobKey) == 1 then
95
- moveParentToWaitIfNeeded(parentData['queueKey'], dependenciesSet,
96
- parentKey, parentData['id'], timestamp)
97
- if opts['idof'] then
98
- local failedSet = parentKey .. ":failed"
99
- rcall("HSET", failedSet, jobKey, failedReason)
100
- end
101
- end
102
- end
103
- end
76
+ moveChildFromDependenciesIfNeeded(rawParentData, jobKey, failedReason, timestamp)
104
77
 
105
78
  removeJobsOnFail(ARGV[5], failedKey, jobId, opts, timestamp)
106
79
 
@@ -1,14 +1,15 @@
1
1
  --[[
2
- Remove a job from all the queues it may be in as well as all its data.
2
+ Remove a job from all the statuses it may be in as well as all its data.
3
3
  In order to be able to remove a job, it cannot be active.
4
4
 
5
5
  Input:
6
- KEYS[1] queue prefix
6
+ KEYS[1] jobKey
7
7
  KEYS[2] meta key
8
8
  KEYS[3] repeat key
9
9
 
10
10
  ARGV[1] jobId
11
11
  ARGV[2] remove children
12
+ ARGV[3] queue prefix
12
13
 
13
14
  Events:
14
15
  'removed'
@@ -17,80 +18,15 @@
17
18
  local rcall = redis.call
18
19
 
19
20
  -- Includes
20
- --- @include "includes/destructureJobKey"
21
- --- @include "includes/getOrSetMaxEvents"
22
21
  --- @include "includes/isJobSchedulerJob"
23
22
  --- @include "includes/isLocked"
24
- --- @include "includes/removeDeduplicationKey"
25
- --- @include "includes/removeJobFromAnyState"
26
- --- @include "includes/removeJobKeys"
27
- --- @include "includes/removeParentDependencyKey"
23
+ --- @include "includes/removeJobWithChildren"
28
24
 
29
- local function removeJob(prefix, jobId, parentKey, removeChildren)
30
- local jobKey = prefix .. jobId;
31
-
32
- removeParentDependencyKey(jobKey, false, parentKey, nil)
33
-
34
- if removeChildren == "1" then
35
- -- Check if this job has children
36
- -- If so, we are going to try to remove the children recursively in deep first way because
37
- -- if some job is locked we must exit with and error.
38
- -- local countProcessed = rcall("HLEN", jobKey .. ":processed")
39
- local processed = rcall("HGETALL", jobKey .. ":processed")
40
-
41
- if (#processed > 0) then
42
- for i = 1, #processed, 2 do
43
- local childJobId = getJobIdFromKey(processed[i])
44
- local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)
45
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
46
- end
47
- end
48
-
49
- local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
50
- if (#dependencies > 0) then
51
- for i, childJobKey in ipairs(dependencies) do
52
- -- We need to get the jobId for this job.
53
- local childJobId = getJobIdFromKey(childJobKey)
54
- local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
55
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
56
- end
57
- end
58
-
59
- local failed = rcall("HGETALL", jobKey .. ":failed")
60
-
61
- if (#failed > 0) then
62
- for i = 1, #failed, 2 do
63
- local childJobId = getJobIdFromKey(failed[i])
64
- local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)
65
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
66
- end
67
- end
68
-
69
- local unsuccessful = rcall("ZRANGE", jobKey .. ":unsuccessful", 0, -1)
70
-
71
- if (#unsuccessful > 0) then
72
- for i = 1, #unsuccessful, 1 do
73
- local childJobId = getJobIdFromKey(unsuccessful[i])
74
- local childJobPrefix = getJobKeyPrefix(unsuccessful[i], childJobId)
75
- removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
76
- end
77
- end
78
- end
79
-
80
- local prev = removeJobFromAnyState(prefix, jobId)
81
-
82
- removeDeduplicationKey(prefix, jobKey)
83
- if removeJobKeys(jobKey) > 0 then
84
- local maxEvents = getOrSetMaxEvents(KEYS[2])
85
- rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev",
86
- prev)
87
- end
88
- end
89
-
90
- local prefix = KEYS[1]
91
25
  local jobId = ARGV[1]
92
26
  local shouldRemoveChildren = ARGV[2]
93
- local jobKey = prefix .. jobId
27
+ local prefix = ARGV[3]
28
+ local jobKey = KEYS[1]
29
+ local meta = KEYS[2]
94
30
  local repeatKey = KEYS[3]
95
31
 
96
32
  if isJobSchedulerJob(jobId, jobKey, repeatKey) then
@@ -98,7 +34,13 @@ if isJobSchedulerJob(jobId, jobKey, repeatKey) then
98
34
  end
99
35
 
100
36
  if not isLocked(prefix, jobId, shouldRemoveChildren) then
101
- removeJob(prefix, jobId, nil, shouldRemoveChildren)
37
+ local options = {
38
+ removeChildren = shouldRemoveChildren == "1",
39
+ ignoreProcessed = false,
40
+ ignoreLocked = false
41
+ }
42
+
43
+ removeJobWithChildren(prefix, meta, jobId, nil, options)
102
44
  return 1
103
45
  end
104
46
  return 0
@@ -0,0 +1,31 @@
1
+ --[[
2
+ Remove a job from all the statuses it may be in as well as all its data.
3
+ In order to be able to remove a job, it cannot be active.
4
+
5
+ Input:
6
+ KEYS[1] jobKey
7
+ KEYS[2] meta key
8
+
9
+ ARGV[1] prefix
10
+ ARGV[2] jobId
11
+
12
+ Events:
13
+ 'removed' for every children removed
14
+ ]]
15
+
16
+ -- Includes
17
+ --- @include "includes/removeJobWithChildren"
18
+
19
+ local prefix = ARGV[1]
20
+ local jobId = ARGV[2]
21
+
22
+ local jobKey = KEYS[1]
23
+ local metaKey = KEYS[2]
24
+
25
+ local options = {
26
+ removeChildren = "1",
27
+ ignoreProcessed = true,
28
+ ignoreLocked = true
29
+ }
30
+
31
+ removeJobChildren(prefix, metaKey, jobKey, options)
@@ -25,7 +25,8 @@
25
25
 
26
26
  Output:
27
27
  next delayed job id - OK
28
- ]] local rcall = redis.call
28
+ ]]
29
+ local rcall = redis.call
29
30
  local repeatKey = KEYS[1]
30
31
  local delayedKey = KEYS[2]
31
32
  local waitKey = KEYS[3]
@@ -48,37 +49,42 @@ local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
48
49
 
49
50
  -- Validate that scheduler exists.
50
51
  local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
51
- if prevMillis ~= false then
52
+ if prevMillis then
52
53
  local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
53
54
 
54
- if producerId == currentDelayedJobId and rcall("EXISTS", nextDelayedJobKey) ~= 1 then
55
- local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
56
-
57
- rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
58
- rcall("HINCRBY", schedulerKey, "ic", 1)
59
-
55
+ if producerId == currentDelayedJobId then
60
56
  local eventsKey = KEYS[9]
61
57
  local maxEvents = getOrSetMaxEvents(metaKey)
62
58
 
63
- rcall("INCR", KEYS[8])
59
+ if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
60
+ local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
64
61
 
65
- -- TODO: remove this workaround in next breaking change,
66
- -- all job-schedulers must save job data
67
- local templateData = schedulerAttributes[2] or ARGV[3]
62
+ rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
63
+ rcall("HINCRBY", schedulerKey, "ic", 1)
68
64
 
69
- if templateData and templateData ~= '{}' then
70
- rcall("HSET", schedulerKey, "data", templateData)
71
- end
65
+ rcall("INCR", KEYS[8])
72
66
 
73
- addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
74
- KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
75
- schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
67
+ -- TODO: remove this workaround in next breaking change,
68
+ -- all job-schedulers must save job data
69
+ local templateData = schedulerAttributes[2] or ARGV[3]
76
70
 
77
- -- TODO: remove this workaround in next breaking change
78
- if KEYS[11] ~= "" then
79
- rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
80
- end
71
+ if templateData and templateData ~= '{}' then
72
+ rcall("HSET", schedulerKey, "data", templateData)
73
+ end
81
74
 
82
- return nextDelayedJobId .. "" -- convert to string
75
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
76
+ KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
77
+ schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
78
+
79
+ -- TODO: remove this workaround in next breaking change
80
+ if KEYS[11] ~= "" then
81
+ rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
82
+ end
83
+
84
+ return nextDelayedJobId .. "" -- convert to string
85
+ else
86
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
87
+ "duplicated", "jobId", nextDelayedJobId)
88
+ end
83
89
  end
84
90
  end
@@ -114,25 +114,25 @@ local function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,
114
114
  end
115
115
  --[[
116
116
  Function to debounce a job.
117
- ]]
117
+ ]]
118
118
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
119
119
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
120
120
  if deduplicationId then
121
- local ttl = deduplicationOpts['ttl']
122
- local deduplicationKeyExists
123
- if ttl then
124
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
125
- else
126
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
127
- end
128
- if deduplicationKeyExists then
129
- local currentDebounceJobId = rcall('GET', deduplicationKey)
130
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
131
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
132
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
133
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
134
- return currentDebounceJobId
135
- end
121
+ local ttl = deduplicationOpts['ttl']
122
+ local deduplicationKeyExists
123
+ if ttl then
124
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
125
+ else
126
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
127
+ end
128
+ if deduplicationKeyExists then
129
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
130
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
131
+ "debounceId", deduplicationId)
132
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
133
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
134
+ return currentDebounceJobId
135
+ end
136
136
  end
137
137
  end
138
138
  --[[
@@ -162,7 +162,16 @@ end
162
162
  ]]
163
163
  -- Includes
164
164
  --[[
165
- Validate and move parent to active if needed.
165
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
166
+ if no pending dependencies.
167
+ ]]
168
+ -- Includes
169
+ --[[
170
+ Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
171
+ ]]
172
+ -- Includes
173
+ --[[
174
+ Move parent to a wait status (wait, prioritized or delayed)
166
175
  ]]
167
176
  -- Includes
168
177
  --[[
@@ -234,51 +243,60 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
234
243
  end
235
244
  return waitKey, false
236
245
  end
237
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
238
- parentKey, parentId, timestamp)
239
- local isParentActive = rcall("ZSCORE",
240
- parentQueueKey .. ":waiting-children", parentId)
241
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
242
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
243
- local parentWaitKey = parentQueueKey .. ":wait"
244
- local parentPausedKey = parentQueueKey .. ":paused"
245
- local parentActiveKey = parentQueueKey .. ":active"
246
- local parentMetaKey = parentQueueKey .. ":meta"
247
- local parentMarkerKey = parentQueueKey .. ":marker"
248
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
249
- local priority = tonumber(jobAttributes[1]) or 0
250
- local delay = tonumber(jobAttributes[2]) or 0
251
- if delay > 0 then
252
- local delayedTimestamp = tonumber(timestamp) + delay
253
- local score = delayedTimestamp * 0x1000
254
- local parentDelayedKey = parentQueueKey .. ":delayed"
255
- rcall("ZADD", parentDelayedKey, score, parentId)
256
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
257
- "jobId", parentId, "delay", delayedTimestamp)
258
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
246
+ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
247
+ local parentWaitKey = parentQueueKey .. ":wait"
248
+ local parentPausedKey = parentQueueKey .. ":paused"
249
+ local parentActiveKey = parentQueueKey .. ":active"
250
+ local parentMetaKey = parentQueueKey .. ":meta"
251
+ local parentMarkerKey = parentQueueKey .. ":marker"
252
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
253
+ local priority = tonumber(jobAttributes[1]) or 0
254
+ local delay = tonumber(jobAttributes[2]) or 0
255
+ -- ignore dependencies if any left
256
+ rcall("HSET", parentKey, "igdp", 1)
257
+ if delay > 0 then
258
+ local delayedTimestamp = tonumber(timestamp) + delay
259
+ local score = delayedTimestamp * 0x1000
260
+ local parentDelayedKey = parentQueueKey .. ":delayed"
261
+ rcall("ZADD", parentDelayedKey, score, parentId)
262
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
263
+ delayedTimestamp)
264
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
265
+ else
266
+ if priority == 0 then
267
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
268
+ parentWaitKey, parentPausedKey)
269
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
259
270
  else
260
- if priority == 0 then
261
- local parentTarget, isParentPausedOrMaxed =
262
- getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
263
- parentPausedKey)
264
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
265
- parentId)
266
- else
267
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
268
- addJobWithPriority(parentMarkerKey,
269
- parentQueueKey .. ":prioritized", priority,
270
- parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
271
- end
272
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
273
- "jobId", parentId, "prev", "waiting-children")
271
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
272
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
273
+ parentQueueKey .. ":pc", isPausedOrMaxed)
274
274
  end
275
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
276
+ "waiting-children")
275
277
  end
276
278
  end
279
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
280
+ if rcall("EXISTS", parentKey) == 1 then
281
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
282
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
283
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
284
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
285
+ end
286
+ end
287
+ end
288
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
289
+ parentId, timestamp)
290
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
291
+ if doNotHavePendingDependencies then
292
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
293
+ end
294
+ end
277
295
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
278
296
  parentId, jobIdKey, returnvalue, timestamp )
279
297
  local processedSet = parentKey .. ":processed"
280
298
  rcall("HSET", processedSet, jobIdKey, returnvalue)
281
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
299
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
282
300
  end
283
301
  local function updateExistingJobsParent(parentKey, parent, parentData,
284
302
  parentDependenciesKey, completedKey,
@@ -330,7 +348,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
330
348
  table.insert(optionalValues, "parent")
331
349
  table.insert(optionalValues, parentData)
332
350
  end
333
- if repeatJobKey ~= nil then
351
+ if repeatJobKey then
334
352
  table.insert(optionalValues, "rjk")
335
353
  table.insert(optionalValues, repeatJobKey)
336
354
  end
@@ -1 +1 @@
1
- {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyXf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Yf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -39,6 +39,7 @@ local waitKey = KEYS[3]
39
39
  local pausedKey = KEYS[4]
40
40
  local metaKey = KEYS[5]
41
41
  local prioritizedKey = KEYS[6]
42
+ local eventsKey = KEYS[9]
42
43
  local nextMillis = ARGV[1]
43
44
  local jobSchedulerId = ARGV[3]
44
45
  local templateOpts = cmsgpack.unpack(ARGV[5])
@@ -160,7 +161,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
160
161
  table.insert(optionalValues, "parent")
161
162
  table.insert(optionalValues, parentData)
162
163
  end
163
- if repeatJobKey ~= nil then
164
+ if repeatJobKey then
164
165
  table.insert(optionalValues, "rjk")
165
166
  table.insert(optionalValues, repeatJobKey)
166
167
  end
@@ -240,13 +241,18 @@ end
240
241
  ]]
241
242
  -- Includes
242
243
  --[[
243
- Function to remove deduplication key.
244
+ Function to remove deduplication key if needed
245
+ when a job is being removed.
244
246
  ]]
245
- local function removeDeduplicationKey(prefixKey, jobKey)
247
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
248
+ jobKey, jobId)
246
249
  local deduplicationId = rcall("HGET", jobKey, "deid")
247
250
  if deduplicationId then
248
251
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
249
- rcall("DEL", deduplicationKey)
252
+ local currentJobId = rcall('GET', deduplicationKey)
253
+ if currentJobId and currentJobId == jobId then
254
+ return rcall("DEL", deduplicationKey)
255
+ end
250
256
  end
251
257
  end
252
258
  --[[
@@ -272,7 +278,7 @@ end
272
278
  local getJobKeyPrefix = function (jobKey, jobId)
273
279
  return string.sub(jobKey, 0, #jobKey - #jobId)
274
280
  end
275
- local function moveParentToWait(parentPrefix, parentId, emitEvent)
281
+ local function _moveParentToWait(parentPrefix, parentId, emitEvent)
276
282
  local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
277
283
  parentPrefix .. "wait", parentPrefix .. "paused")
278
284
  addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
@@ -300,10 +306,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
300
306
  rcall("DEL", parentPrefix .. "de:" .. debounceId)
301
307
  end
302
308
  else
303
- moveParentToWait(parentPrefix, parentId)
309
+ _moveParentToWait(parentPrefix, parentId)
304
310
  end
305
311
  else
306
- moveParentToWait(parentPrefix, parentId, true)
312
+ _moveParentToWait(parentPrefix, parentId, true)
307
313
  end
308
314
  end
309
315
  end
@@ -331,10 +337,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
331
337
  rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
332
338
  end
333
339
  else
334
- moveParentToWait(parentPrefix, parentId)
340
+ _moveParentToWait(parentPrefix, parentId)
335
341
  end
336
342
  else
337
- moveParentToWait(parentPrefix, parentId, true)
343
+ _moveParentToWait(parentPrefix, parentId, true)
338
344
  end
339
345
  end
340
346
  end
@@ -348,7 +354,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
348
354
  local jobKey = baseKey .. jobId
349
355
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
350
356
  if shouldRemoveDeduplicationKey then
351
- removeDeduplicationKey(baseKey, jobKey)
357
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
352
358
  end
353
359
  removeJobKeys(jobKey)
354
360
  end
@@ -395,43 +401,56 @@ end
395
401
  local schedulerKey = repeatKey .. ":" .. jobSchedulerId
396
402
  local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
397
403
  local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
404
+ local maxEvents = getOrSetMaxEvents(metaKey)
405
+ local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,
406
+ metaKey, eventsKey)
407
+ if rcall("ZSCORE", delayedKey, jobId) then
408
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
409
+ rcall("ZREM", delayedKey, jobId)
410
+ return true
411
+ elseif rcall("ZSCORE", prioritizedKey, jobId) then
412
+ removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
413
+ rcall("ZREM", prioritizedKey, jobId)
414
+ return true
415
+ else
416
+ local pausedOrWaitKey = waitKey
417
+ if isQueuePaused(metaKey) then
418
+ pausedOrWaitKey = pausedKey
419
+ end
420
+ if rcall("LREM", pausedOrWaitKey, 1, jobId) > 0 then
421
+ removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
422
+ return true
423
+ end
424
+ end
425
+ return false
426
+ end
427
+ if rcall("EXISTS", nextDelayedJobKey) == 1 then
428
+ if not removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
429
+ nextDelayedJobId, metaKey, eventsKey) then
430
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
431
+ "duplicated", "jobId", nextDelayedJobId)
432
+ return nextDelayedJobId .. "" -- convert to string
433
+ end
434
+ end
398
435
  local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
399
- if prevMillis ~= false then
436
+ if prevMillis then
400
437
  local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
401
- if rcall("EXISTS", nextDelayedJobKey) ~= 1 or currentJobId == nextDelayedJobId then
402
- if rcall("ZSCORE", delayedKey, currentJobId) ~= false then
403
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
404
- rcall("ZREM", delayedKey, currentJobId)
405
- elseif rcall("ZSCORE", prioritizedKey, currentJobId) ~= false then
406
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
407
- rcall("ZREM", prioritizedKey, currentJobId)
408
- else
409
- if isQueuePaused(metaKey) then
410
- if rcall("LREM", pausedKey, 1, currentJobId) > 0 then
411
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
412
- end
413
- else
414
- if rcall("LREM", waitKey, 1, currentJobId) > 0 then
415
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
416
- end
417
- end
418
- end
438
+ local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
439
+ if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
440
+ removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey,
441
+ currentJobId, metaKey, eventsKey)
419
442
  end
420
443
  end
421
444
  local schedulerOpts = cmsgpack.unpack(ARGV[2])
422
445
  storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
423
- if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
424
- local eventsKey = KEYS[9]
425
- local maxEvents = getOrSetMaxEvents(metaKey)
426
- rcall("INCR", KEYS[8])
427
- addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
428
- KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
429
- schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
430
- if ARGV[9] ~= "" then
431
- rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
432
- end
433
- return nextDelayedJobId .. "" -- convert to string
446
+ rcall("INCR", KEYS[8])
447
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
448
+ KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
449
+ schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
450
+ if ARGV[9] ~= "" then
451
+ rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
434
452
  end
453
+ return nextDelayedJobId .. "" -- convert to string
435
454
  `;
436
455
  exports.addJobScheduler = {
437
456
  name: 'addJobScheduler',
@@ -1 +1 @@
1
- {"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+af,CAAC;AACW,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkcf,CAAC;AACW,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}