bullmq 4.16.0 → 5.0.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 (192) hide show
  1. package/dist/cjs/classes/flow-producer.js +3 -10
  2. package/dist/cjs/classes/flow-producer.js.map +1 -1
  3. package/dist/cjs/classes/job.js +21 -11
  4. package/dist/cjs/classes/job.js.map +1 -1
  5. package/dist/cjs/classes/queue-base.js +2 -9
  6. package/dist/cjs/classes/queue-base.js.map +1 -1
  7. package/dist/cjs/classes/queue-events.js +3 -1
  8. package/dist/cjs/classes/queue-events.js.map +1 -1
  9. package/dist/cjs/classes/queue-keys.js +1 -0
  10. package/dist/cjs/classes/queue-keys.js.map +1 -1
  11. package/dist/cjs/classes/redis-connection.js +9 -7
  12. package/dist/cjs/classes/redis-connection.js.map +1 -1
  13. package/dist/cjs/classes/scripts.js +34 -34
  14. package/dist/cjs/classes/scripts.js.map +1 -1
  15. package/dist/cjs/classes/worker.js +41 -37
  16. package/dist/cjs/classes/worker.js.map +1 -1
  17. package/dist/cjs/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
  18. package/dist/cjs/commands/addParentJob-4.lua +0 -2
  19. package/dist/{esm/commands/addPrioritizedJob-8.lua → cjs/commands/addPrioritizedJob-7.lua} +18 -24
  20. package/dist/cjs/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
  21. package/dist/cjs/commands/changePriority-6.lua +57 -0
  22. package/dist/cjs/commands/getCounts-1.lua +1 -0
  23. package/dist/cjs/commands/getRanges-1.lua +1 -0
  24. package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
  25. package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -7
  26. package/dist/cjs/commands/includes/checkStalledJobs.lua +1 -1
  27. package/dist/cjs/commands/includes/isQueuePaused.lua +7 -0
  28. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
  29. package/dist/cjs/commands/includes/prepareJobForProcessing.lua +1 -1
  30. package/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -4
  31. package/dist/{esm/commands/moveToActive-10.lua → cjs/commands/moveToActive-11.lua} +18 -29
  32. package/dist/cjs/commands/moveToDelayed-7.lua +77 -0
  33. package/dist/cjs/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
  34. package/dist/cjs/commands/moveToWaitingChildren-4.lua +7 -4
  35. package/dist/cjs/commands/pause-7.lua +41 -0
  36. package/dist/cjs/commands/promote-8.lua +60 -0
  37. package/dist/cjs/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
  38. package/dist/cjs/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
  39. package/dist/cjs/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
  40. package/dist/cjs/scripts/addParentJob-4.js +51 -61
  41. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  42. package/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
  43. package/dist/cjs/scripts/addPrioritizedJob-7.js.map +1 -0
  44. package/dist/cjs/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
  45. package/dist/cjs/scripts/addStandardJob-7.js.map +1 -0
  46. package/dist/cjs/scripts/changePriority-6.js +85 -0
  47. package/dist/cjs/scripts/changePriority-6.js.map +1 -0
  48. package/dist/cjs/scripts/getCounts-1.js +1 -0
  49. package/dist/cjs/scripts/getCounts-1.js.map +1 -1
  50. package/dist/cjs/scripts/getRanges-1.js +1 -0
  51. package/dist/cjs/scripts/getRanges-1.js.map +1 -1
  52. package/dist/cjs/scripts/index.js +10 -10
  53. package/dist/cjs/scripts/index.js.map +1 -1
  54. package/dist/cjs/scripts/moveStalledJobsToWait-8.js +1 -0
  55. package/dist/cjs/scripts/moveStalledJobsToWait-8.js.map +1 -1
  56. package/dist/cjs/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
  57. package/dist/cjs/scripts/moveToActive-11.js.map +1 -0
  58. package/dist/cjs/scripts/moveToDelayed-7.js +103 -0
  59. package/dist/cjs/scripts/moveToDelayed-7.js.map +1 -0
  60. package/dist/cjs/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
  61. package/dist/cjs/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
  62. package/dist/cjs/scripts/moveToWaitingChildren-4.js +6 -3
  63. package/dist/cjs/scripts/moveToWaitingChildren-4.js.map +1 -1
  64. package/dist/cjs/scripts/pause-7.js +67 -0
  65. package/dist/cjs/scripts/pause-7.js.map +1 -0
  66. package/dist/cjs/scripts/promote-8.js +79 -0
  67. package/dist/cjs/scripts/promote-8.js.map +1 -0
  68. package/dist/cjs/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
  69. package/dist/cjs/scripts/retryJob-10.js.map +1 -0
  70. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  71. package/dist/esm/classes/flow-producer.js +3 -10
  72. package/dist/esm/classes/flow-producer.js.map +1 -1
  73. package/dist/esm/classes/job.d.ts +5 -0
  74. package/dist/esm/classes/job.js +21 -11
  75. package/dist/esm/classes/job.js.map +1 -1
  76. package/dist/esm/classes/queue-base.js +2 -9
  77. package/dist/esm/classes/queue-base.js.map +1 -1
  78. package/dist/esm/classes/queue-events.js +3 -1
  79. package/dist/esm/classes/queue-events.js.map +1 -1
  80. package/dist/esm/classes/queue-keys.js +1 -0
  81. package/dist/esm/classes/queue-keys.js.map +1 -1
  82. package/dist/esm/classes/redis-connection.js +9 -7
  83. package/dist/esm/classes/redis-connection.js.map +1 -1
  84. package/dist/esm/classes/scripts.d.ts +4 -4
  85. package/dist/esm/classes/scripts.js +34 -34
  86. package/dist/esm/classes/scripts.js.map +1 -1
  87. package/dist/esm/classes/worker.d.ts +4 -2
  88. package/dist/esm/classes/worker.js +41 -37
  89. package/dist/esm/classes/worker.js.map +1 -1
  90. package/dist/esm/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
  91. package/dist/esm/commands/addParentJob-4.lua +0 -2
  92. package/dist/{cjs/commands/addPrioritizedJob-8.lua → esm/commands/addPrioritizedJob-7.lua} +18 -24
  93. package/dist/esm/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
  94. package/dist/esm/commands/changePriority-6.lua +57 -0
  95. package/dist/esm/commands/getCounts-1.lua +1 -0
  96. package/dist/esm/commands/getRanges-1.lua +1 -0
  97. package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
  98. package/dist/esm/commands/includes/addJobWithPriority.lua +3 -7
  99. package/dist/esm/commands/includes/checkStalledJobs.lua +1 -1
  100. package/dist/esm/commands/includes/isQueuePaused.lua +7 -0
  101. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
  102. package/dist/esm/commands/includes/prepareJobForProcessing.lua +1 -1
  103. package/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -4
  104. package/dist/{cjs/commands/moveToActive-10.lua → esm/commands/moveToActive-11.lua} +18 -29
  105. package/dist/esm/commands/moveToDelayed-7.lua +77 -0
  106. package/dist/esm/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
  107. package/dist/esm/commands/moveToWaitingChildren-4.lua +7 -4
  108. package/dist/esm/commands/pause-7.lua +41 -0
  109. package/dist/esm/commands/promote-8.lua +60 -0
  110. package/dist/esm/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
  111. package/dist/esm/interfaces/job-json.d.ts +4 -1
  112. package/dist/esm/interfaces/minimal-job.d.ts +3 -0
  113. package/dist/esm/interfaces/queue-options.d.ts +1 -1
  114. package/dist/esm/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
  115. package/dist/esm/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
  116. package/dist/esm/scripts/addParentJob-4.js +51 -61
  117. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  118. package/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
  119. package/dist/esm/scripts/addPrioritizedJob-7.js.map +1 -0
  120. package/dist/esm/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
  121. package/dist/esm/scripts/addStandardJob-7.js.map +1 -0
  122. package/dist/esm/scripts/changePriority-6.js +82 -0
  123. package/dist/esm/scripts/changePriority-6.js.map +1 -0
  124. package/dist/esm/scripts/getCounts-1.js +1 -0
  125. package/dist/esm/scripts/getCounts-1.js.map +1 -1
  126. package/dist/esm/scripts/getRanges-1.js +1 -0
  127. package/dist/esm/scripts/getRanges-1.js.map +1 -1
  128. package/dist/esm/scripts/index.d.ts +10 -10
  129. package/dist/esm/scripts/index.js +10 -10
  130. package/dist/esm/scripts/index.js.map +1 -1
  131. package/dist/esm/scripts/moveStalledJobsToWait-8.js +1 -0
  132. package/dist/esm/scripts/moveStalledJobsToWait-8.js.map +1 -1
  133. package/dist/esm/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
  134. package/dist/esm/scripts/moveToActive-11.js.map +1 -0
  135. package/dist/esm/scripts/moveToDelayed-7.js +100 -0
  136. package/dist/esm/scripts/moveToDelayed-7.js.map +1 -0
  137. package/dist/esm/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
  138. package/dist/esm/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
  139. package/dist/esm/scripts/moveToWaitingChildren-4.js +6 -3
  140. package/dist/esm/scripts/moveToWaitingChildren-4.js.map +1 -1
  141. package/dist/esm/scripts/pause-7.js +64 -0
  142. package/dist/esm/scripts/pause-7.js.map +1 -0
  143. package/dist/esm/scripts/promote-8.js +76 -0
  144. package/dist/esm/scripts/promote-8.js.map +1 -0
  145. package/dist/esm/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
  146. package/dist/esm/scripts/retryJob-10.js.map +1 -0
  147. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  148. package/package.json +1 -1
  149. package/dist/cjs/commands/changePriority-5.lua +0 -52
  150. package/dist/cjs/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
  151. package/dist/cjs/commands/moveToDelayed-8.lua +0 -72
  152. package/dist/cjs/commands/pause-5.lua +0 -36
  153. package/dist/cjs/commands/promote-7.lua +0 -57
  154. package/dist/cjs/scripts/addDelayedJob-7.js.map +0 -1
  155. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +0 -1
  156. package/dist/cjs/scripts/addStandardJob-6.js.map +0 -1
  157. package/dist/cjs/scripts/changePriority-5.js +0 -87
  158. package/dist/cjs/scripts/changePriority-5.js.map +0 -1
  159. package/dist/cjs/scripts/moveToDelayed-8.js +0 -168
  160. package/dist/cjs/scripts/moveToDelayed-8.js.map +0 -1
  161. package/dist/cjs/scripts/pause-5.js +0 -48
  162. package/dist/cjs/scripts/pause-5.js.map +0 -1
  163. package/dist/cjs/scripts/promote-7.js +0 -87
  164. package/dist/cjs/scripts/promote-7.js.map +0 -1
  165. package/dist/cjs/scripts/retryJob-9.js.map +0 -1
  166. package/dist/esm/commands/changePriority-5.lua +0 -52
  167. package/dist/esm/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
  168. package/dist/esm/commands/moveToDelayed-8.lua +0 -72
  169. package/dist/esm/commands/pause-5.lua +0 -36
  170. package/dist/esm/commands/promote-7.lua +0 -57
  171. package/dist/esm/scripts/addDelayedJob-7.js.map +0 -1
  172. package/dist/esm/scripts/addPrioritizedJob-8.js.map +0 -1
  173. package/dist/esm/scripts/addStandardJob-6.js.map +0 -1
  174. package/dist/esm/scripts/changePriority-5.js +0 -84
  175. package/dist/esm/scripts/changePriority-5.js.map +0 -1
  176. package/dist/esm/scripts/moveToDelayed-8.js +0 -165
  177. package/dist/esm/scripts/moveToDelayed-8.js.map +0 -1
  178. package/dist/esm/scripts/pause-5.js +0 -45
  179. package/dist/esm/scripts/pause-5.js.map +0 -1
  180. package/dist/esm/scripts/promote-7.js +0 -84
  181. package/dist/esm/scripts/promote-7.js.map +0 -1
  182. package/dist/esm/scripts/retryJob-9.js.map +0 -1
  183. /package/dist/esm/scripts/{addDelayedJob-7.d.ts → addDelayedJob-6.d.ts} +0 -0
  184. /package/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-7.d.ts} +0 -0
  185. /package/dist/esm/scripts/{addStandardJob-6.d.ts → addStandardJob-7.d.ts} +0 -0
  186. /package/dist/esm/scripts/{changePriority-5.d.ts → changePriority-6.d.ts} +0 -0
  187. /package/dist/esm/scripts/{moveToActive-10.d.ts → moveToActive-11.d.ts} +0 -0
  188. /package/dist/esm/scripts/{moveToDelayed-8.d.ts → moveToDelayed-7.d.ts} +0 -0
  189. /package/dist/esm/scripts/{moveToFinished-13.d.ts → moveToFinished-14.d.ts} +0 -0
  190. /package/dist/esm/scripts/{pause-5.d.ts → pause-7.d.ts} +0 -0
  191. /package/dist/esm/scripts/{promote-7.d.ts → promote-8.d.ts} +0 -0
  192. /package/dist/esm/scripts/{retryJob-9.d.ts → retryJob-10.d.ts} +0 -0
@@ -1,84 +0,0 @@
1
- const content = `--[[
2
- Change job priority
3
- Input:
4
- KEYS[1] 'wait',
5
- KEYS[2] 'paused'
6
- KEYS[3] 'meta'
7
- KEYS[4] 'prioritized'
8
- KEYS[5] 'pc' priority counter
9
- ARGV[1] priority value
10
- ARGV[2] job key
11
- ARGV[3] job id
12
- ARGV[4] lifo
13
- Output:
14
- 0 - OK
15
- -1 - Missing job
16
- ]]
17
- local jobKey = ARGV[2]
18
- local jobId = ARGV[3]
19
- local priority = tonumber(ARGV[1])
20
- local rcall = redis.call
21
- -- Includes
22
- --[[
23
- Function to add job considering priority.
24
- ]]
25
- -- Includes
26
- --[[
27
- Function priority marker to wait if needed
28
- in order to wake up our workers and to respect priority
29
- order as much as possible
30
- ]]
31
- local function addPriorityMarkerIfNeeded(waitKey)
32
- local waitLen = rcall("LLEN", waitKey)
33
- if waitLen == 0 then
34
- rcall("LPUSH", waitKey, "0:0")
35
- end
36
- end
37
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
38
- local prioCounter = rcall("INCR", priorityCounterKey)
39
- local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
40
- rcall("ZADD", prioritizedKey, score, jobId)
41
- if not paused then
42
- addPriorityMarkerIfNeeded(waitKey)
43
- end
44
- end
45
- --[[
46
- Function to check for the meta.paused key to decide if we are paused or not
47
- (since an empty list and !EXISTS are not really the same).
48
- ]]
49
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
50
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
51
- return waitKey, false
52
- else
53
- return pausedKey, true
54
- end
55
- end
56
- if rcall("EXISTS", jobKey) == 1 then
57
- local target, paused = getTargetQueueList(KEYS[3], KEYS[1], KEYS[2])
58
- if rcall("ZREM", KEYS[4], jobId) > 0 then
59
- addJobWithPriority(KEYS[1], KEYS[4], priority, paused, jobId, KEYS[5])
60
- else
61
- local numRemovedElements = rcall("LREM", target, -1, jobId)
62
- if numRemovedElements > 0 then
63
- -- Standard or priority add
64
- if priority == 0 then
65
- -- LIFO or FIFO
66
- local pushCmd = ARGV[4] == '1' and 'RPUSH' or 'LPUSH';
67
- rcall(pushCmd, target, jobId)
68
- else
69
- addJobWithPriority(KEYS[1], KEYS[4], priority, paused, jobId, KEYS[5])
70
- end
71
- end
72
- end
73
- rcall("HSET", jobKey, "priority", priority)
74
- return 0
75
- else
76
- return -1
77
- end
78
- `;
79
- export const changePriority = {
80
- name: 'changePriority',
81
- content,
82
- keys: 5,
83
- };
84
- //# sourceMappingURL=changePriority-5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"changePriority-5.js","sourceRoot":"","sources":["../../../src/scripts/changePriority-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ef,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -1,165 +0,0 @@
1
- const content = `--[[
2
- Moves job from active to delayed set.
3
- Input:
4
- KEYS[1] wait key
5
- KEYS[2] active key
6
- KEYS[3] prioritized key
7
- KEYS[4] delayed key
8
- KEYS[5] job key
9
- KEYS[6] events stream
10
- KEYS[7] paused key
11
- KEYS[8] meta key
12
- ARGV[1] key prefix
13
- ARGV[2] timestamp
14
- ARGV[3] delayedTimestamp
15
- ARGV[4] the id of the job
16
- ARGV[5] queue token
17
- ARGV[6] delay value
18
- Output:
19
- 0 - OK
20
- -1 - Missing job.
21
- -3 - Job not in active set.
22
- Events:
23
- - delayed key.
24
- ]]
25
- local rcall = redis.call
26
- -- Includes
27
- --[[
28
- Add delay marker if needed.
29
- ]]
30
- -- Includes
31
- --[[
32
- Function to return the next delayed job timestamp.
33
- ]]
34
- local function getNextDelayedTimestamp(delayedKey)
35
- local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
36
- if #result then
37
- local nextTimestamp = tonumber(result[2])
38
- if (nextTimestamp ~= nil) then
39
- nextTimestamp = nextTimestamp / 0x1000
40
- end
41
- return nextTimestamp
42
- end
43
- end
44
- local function addDelayMarkerIfNeeded(targetKey, delayedKey)
45
- local waitLen = rcall("LLEN", targetKey)
46
- if waitLen <= 1 then
47
- local nextTimestamp = getNextDelayedTimestamp(delayedKey)
48
- if nextTimestamp ~= nil then
49
- -- Check if there is already a marker with older timestamp
50
- -- if there is, we need to replace it.
51
- if waitLen == 1 then
52
- local marker = rcall("LINDEX", targetKey, 0)
53
- local oldTimestamp = tonumber(marker:sub(3))
54
- if oldTimestamp and oldTimestamp > nextTimestamp then
55
- rcall("LSET", targetKey, 0, "0:" .. nextTimestamp)
56
- end
57
- else
58
- -- if there is no marker, then we need to add one
59
- rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
60
- end
61
- end
62
- end
63
- end
64
- --[[
65
- Function to check for the meta.paused key to decide if we are paused or not
66
- (since an empty list and !EXISTS are not really the same).
67
- ]]
68
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
69
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
70
- return waitKey, false
71
- else
72
- return pausedKey, true
73
- end
74
- end
75
- --[[
76
- Updates the delay set, by moving delayed jobs that should
77
- be processed now to "wait".
78
- Events:
79
- 'waiting'
80
- ]]
81
- -- Includes
82
- --[[
83
- Function to add job considering priority.
84
- ]]
85
- -- Includes
86
- --[[
87
- Function priority marker to wait if needed
88
- in order to wake up our workers and to respect priority
89
- order as much as possible
90
- ]]
91
- local function addPriorityMarkerIfNeeded(waitKey)
92
- local waitLen = rcall("LLEN", waitKey)
93
- if waitLen == 0 then
94
- rcall("LPUSH", waitKey, "0:0")
95
- end
96
- end
97
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
98
- local prioCounter = rcall("INCR", priorityCounterKey)
99
- local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
100
- rcall("ZADD", prioritizedKey, score, jobId)
101
- if not paused then
102
- addPriorityMarkerIfNeeded(waitKey)
103
- end
104
- end
105
- -- Try to get as much as 1000 jobs at once
106
- local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey,
107
- eventStreamKey, prefix, timestamp, paused, priorityCounterKey)
108
- local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
109
- if (#jobs > 0) then
110
- rcall("ZREM", delayedKey, unpack(jobs))
111
- for _, jobId in ipairs(jobs) do
112
- local jobKey = prefix .. jobId
113
- local priority =
114
- tonumber(rcall("HGET", jobKey, "priority")) or 0
115
- if priority == 0 then
116
- -- LIFO or FIFO
117
- rcall("LPUSH", targetKey, jobId)
118
- else
119
- addJobWithPriority(waitKey, prioritizedKey, priority, paused,
120
- jobId, priorityCounterKey)
121
- end
122
- -- Emit waiting event
123
- rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
124
- jobId, "prev", "delayed")
125
- rcall("HSET", jobKey, "delay", 0)
126
- end
127
- end
128
- end
129
- local jobKey = KEYS[5]
130
- if rcall("EXISTS", jobKey) == 1 then
131
- local delayedKey = KEYS[4]
132
- if ARGV[5] ~= "0" then
133
- local lockKey = jobKey .. ':lock'
134
- if rcall("GET", lockKey) == ARGV[5] then
135
- rcall("DEL", lockKey)
136
- else
137
- return -2
138
- end
139
- end
140
- local jobId = ARGV[4]
141
- local score = tonumber(ARGV[3])
142
- local delayedTimestamp = (score / 0x1000)
143
- local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
144
- if numRemovedElements < 1 then
145
- return -3
146
- end
147
- rcall("HSET", jobKey, "delay", ARGV[6])
148
- local maxEvents = rcall("HGET", KEYS[8], "opts.maxLenEvents") or 10000
149
- rcall("ZADD", delayedKey, score, jobId)
150
- rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
151
- "jobId", jobId, "delay", delayedTimestamp)
152
- -- Check if we need to push a marker job to wake up sleeping workers.
153
- local target = getTargetQueueList(KEYS[8], KEYS[1], KEYS[7])
154
- addDelayMarkerIfNeeded(target, delayedKey)
155
- return 0
156
- else
157
- return -1
158
- end
159
- `;
160
- export const moveToDelayed = {
161
- name: 'moveToDelayed',
162
- content,
163
- keys: 8,
164
- };
165
- //# sourceMappingURL=moveToDelayed-8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Jf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -1,45 +0,0 @@
1
- const content = `--[[
2
- Pauses or resumes a queue globably.
3
- Input:
4
- KEYS[1] 'wait' or 'paused''
5
- KEYS[2] 'paused' or 'wait'
6
- KEYS[3] 'meta'
7
- KEYS[4] 'prioritized'
8
- KEYS[5] events stream key
9
- ARGV[1] 'paused' or 'resumed'
10
- Event:
11
- publish paused or resumed event.
12
- ]]
13
- local rcall = redis.call
14
- -- Includes
15
- --[[
16
- Function priority marker to wait if needed
17
- in order to wake up our workers and to respect priority
18
- order as much as possible
19
- ]]
20
- local function addPriorityMarkerIfNeeded(waitKey)
21
- local waitLen = rcall("LLEN", waitKey)
22
- if waitLen == 0 then
23
- rcall("LPUSH", waitKey, "0:0")
24
- end
25
- end
26
- if rcall("EXISTS", KEYS[1]) == 1 then
27
- rcall("RENAME", KEYS[1], KEYS[2])
28
- end
29
- if ARGV[1] == "paused" then
30
- rcall("HSET", KEYS[3], "paused", 1)
31
- else
32
- rcall("HDEL", KEYS[3], "paused")
33
- local priorityCount = rcall("ZCARD", KEYS[4])
34
- if priorityCount > 0 then
35
- addPriorityMarkerIfNeeded(KEYS[2])
36
- end
37
- end
38
- rcall("XADD", KEYS[5], "*", "event", ARGV[1]);
39
- `;
40
- export const pause = {
41
- name: 'pause',
42
- content,
43
- keys: 5,
44
- };
45
- //# sourceMappingURL=pause-5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pause-5.js","sourceRoot":"","sources":["../../../src/scripts/pause-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -1,84 +0,0 @@
1
- const content = `--[[
2
- Promotes a job that is currently "delayed" to the "waiting" state
3
- Input:
4
- KEYS[1] 'delayed'
5
- KEYS[2] 'wait'
6
- KEYS[3] 'paused'
7
- KEYS[4] 'meta'
8
- KEYS[5] 'prioritized'
9
- KEYS[6] 'pc' priority counter
10
- KEYS[7] 'event stream'
11
- ARGV[1] queue.toKey('')
12
- ARGV[2] jobId
13
- Output:
14
- 0 - OK
15
- -3 - Job not in delayed zset.
16
- Events:
17
- 'waiting'
18
- ]]
19
- local rcall = redis.call
20
- local jobId = ARGV[2]
21
- -- Includes
22
- --[[
23
- Function to add job considering priority.
24
- ]]
25
- -- Includes
26
- --[[
27
- Function priority marker to wait if needed
28
- in order to wake up our workers and to respect priority
29
- order as much as possible
30
- ]]
31
- local function addPriorityMarkerIfNeeded(waitKey)
32
- local waitLen = rcall("LLEN", waitKey)
33
- if waitLen == 0 then
34
- rcall("LPUSH", waitKey, "0:0")
35
- end
36
- end
37
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
38
- local prioCounter = rcall("INCR", priorityCounterKey)
39
- local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
40
- rcall("ZADD", prioritizedKey, score, jobId)
41
- if not paused then
42
- addPriorityMarkerIfNeeded(waitKey)
43
- end
44
- end
45
- --[[
46
- Function to check for the meta.paused key to decide if we are paused or not
47
- (since an empty list and !EXISTS are not really the same).
48
- ]]
49
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
50
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
51
- return waitKey, false
52
- else
53
- return pausedKey, true
54
- end
55
- end
56
- if rcall("ZREM", KEYS[1], jobId) == 1 then
57
- local jobKey = ARGV[1] .. jobId
58
- local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0
59
- local target, paused = getTargetQueueList(KEYS[4], KEYS[2], KEYS[3])
60
- -- Remove delayed "marker" from the wait list if there is any.
61
- -- Since we are adding a job we do not need the marker anymore.
62
- local marker = rcall("LINDEX", target, 0)
63
- if marker and string.sub(marker, 1, 2) == "0:" then
64
- rcall("LPOP", target)
65
- end
66
- if priority == 0 then
67
- -- LIFO or FIFO
68
- rcall("LPUSH", target, jobId)
69
- else
70
- addJobWithPriority(KEYS[2], KEYS[5], priority, paused, jobId, KEYS[6])
71
- end
72
- -- Emit waiting event (wait..ing@token)
73
- rcall("XADD", KEYS[7], "*", "event", "waiting", "jobId", jobId, "prev", "delayed");
74
- rcall("HSET", jobKey, "delay", 0)
75
- return 0
76
- else
77
- return -3
78
- end`;
79
- export const promote = {
80
- name: 'promote',
81
- content,
82
- keys: 7,
83
- };
84
- //# sourceMappingURL=promote-7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"promote-7.js","sourceRoot":"","sources":["../../../src/scripts/promote-7.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6EZ,CAAC;AACL,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"retryJob-9.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwHf,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
File without changes