bullmq 5.44.3 → 5.45.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.
@@ -5,7 +5,12 @@ export interface QueueEventsListener extends IoredisListener {
5
5
  /**
6
6
  * Listen to 'active' event.
7
7
  *
8
- * This event is triggered when a job enters the 'active' state.
8
+ * This event is triggered when a job enters the 'active' state, meaning it is being processed.
9
+ *
10
+ * @param args - An object containing details about the job that became active.
11
+ * @param args.jobId - The unique identifier of the job that entered the active state.
12
+ * @param args.prev - The previous state of the job before it became active (e.g., 'waiting'), if applicable.
13
+ * @param id - The identifier of the event.
9
14
  */
10
15
  active: (args: {
11
16
  jobId: string;
@@ -14,7 +19,12 @@ export interface QueueEventsListener extends IoredisListener {
14
19
  /**
15
20
  * Listen to 'added' event.
16
21
  *
17
- * This event is triggered when a job is created.
22
+ * This event is triggered when a job is created and added to the queue.
23
+ *
24
+ * @param args - An object containing details about the newly added job.
25
+ * @param args.jobId - The unique identifier of the job that was added.
26
+ * @param args.name - The name of the job, typically indicating its type or purpose.
27
+ * @param id - The identifier of the event.
18
28
  */
19
29
  added: (args: {
20
30
  jobId: string;
@@ -23,7 +33,11 @@ export interface QueueEventsListener extends IoredisListener {
23
33
  /**
24
34
  * Listen to 'cleaned' event.
25
35
  *
26
- * This event is triggered when a cleaned method is triggered.
36
+ * This event is triggered when jobs are cleaned (e.g., removed) from the queue, typically via a cleanup method.
37
+ *
38
+ * @param args - An object containing the count of cleaned jobs.
39
+ * @param args.count - The number of jobs that were cleaned, represented as a string due to Redis serialization.
40
+ * @param id - The identifier of the event.
27
41
  */
28
42
  cleaned: (args: {
29
43
  count: string;
@@ -31,7 +45,13 @@ export interface QueueEventsListener extends IoredisListener {
31
45
  /**
32
46
  * Listen to 'completed' event.
33
47
  *
34
- * This event is triggered when a job has successfully completed.
48
+ * This event is triggered when a job has successfully completed its execution.
49
+ *
50
+ * @param args - An object containing details about the completed job.
51
+ * @param args.jobId - The unique identifier of the job that completed.
52
+ * @param args.returnvalue - The return value of the job, serialized as a string.
53
+ * @param args.prev - The previous state of the job before completion (e.g., 'active'), if applicable.
54
+ * @param id - The identifier of the event.
35
55
  */
36
56
  completed: (args: {
37
57
  jobId: string;
@@ -40,9 +60,15 @@ export interface QueueEventsListener extends IoredisListener {
40
60
  }, id: string) => void;
41
61
  /**
42
62
  * Listen to 'debounced' event.
43
- * @deprecated use deduplicated event
44
63
  *
45
- * This event is triggered when a job is debounced because debounceId still existed.
64
+ * @deprecated Use the 'deduplicated' event instead.
65
+ *
66
+ * This event is triggered when a job is debounced because a job with the same debounceId still exists.
67
+ *
68
+ * @param args - An object containing details about the debounced job.
69
+ * @param args.jobId - The unique identifier of the job that was debounced.
70
+ * @param args.debounceId - The identifier used to debounce the job, preventing duplicate processing.
71
+ * @param id - The identifier of the event.
46
72
  */
47
73
  debounced: (args: {
48
74
  jobId: string;
@@ -51,16 +77,29 @@ export interface QueueEventsListener extends IoredisListener {
51
77
  /**
52
78
  * Listen to 'deduplicated' event.
53
79
  *
54
- * This event is triggered when a job is deduplicated because deduplicatedId still existed.
80
+ * This event is triggered when a job is not added to the queue because a job with the same deduplicationId
81
+ * already exists.
82
+ *
83
+ * @param args - An object containing details about the deduplicated job.
84
+ * @param args.jobId - The unique identifier of the job that was attempted to be added.
85
+ * @param args.deduplicationId - The deduplication identifier that caused the job to be deduplicated.
86
+ * @param args.deduplicatedJobId - The unique identifier of the existing job that caused the deduplication.
87
+ * @param id - The identifier of the event.
55
88
  */
56
89
  deduplicated: (args: {
57
90
  jobId: string;
58
91
  deduplicationId: string;
92
+ deduplicatedJobId: string;
59
93
  }, id: string) => void;
60
94
  /**
61
95
  * Listen to 'delayed' event.
62
96
  *
63
- * This event is triggered when a job is delayed.
97
+ * This event is triggered when a job is scheduled with a delay before it becomes active.
98
+ *
99
+ * @param args - An object containing details about the delayed job.
100
+ * @param args.jobId - The unique identifier of the job that was delayed.
101
+ * @param args.delay - The delay duration in milliseconds before the job becomes active.
102
+ * @param id - The identifier of the event.
64
103
  */
65
104
  delayed: (args: {
66
105
  jobId: string;
@@ -69,15 +108,22 @@ export interface QueueEventsListener extends IoredisListener {
69
108
  /**
70
109
  * Listen to 'drained' event.
71
110
  *
72
- * This event is triggered when the queue has drained the waiting list.
111
+ * This event is triggered when the queue has drained its waiting list, meaning there are no jobs
112
+ * in the 'waiting' state.
73
113
  * Note that there could still be delayed jobs waiting their timers to expire
74
114
  * and this event will still be triggered as long as the waiting list has emptied.
115
+ *
116
+ * @param id - The identifier of the event.
75
117
  */
76
118
  drained: (id: string) => void;
77
119
  /**
78
120
  * Listen to 'duplicated' event.
79
121
  *
80
- * This event is triggered when a job is not created because it already exist.
122
+ * This event is triggered when a job is not created because a job with the same identifier already exists.
123
+ *
124
+ * @param args - An object containing the job identifier.
125
+ * @param args.jobId - The unique identifier of the job that was attempted to be added.
126
+ * @param id - The identifier of the event.
81
127
  */
82
128
  duplicated: (args: {
83
129
  jobId: string;
@@ -85,13 +131,19 @@ export interface QueueEventsListener extends IoredisListener {
85
131
  /**
86
132
  * Listen to 'error' event.
87
133
  *
88
- * This event is triggered when an exception is thrown.
134
+ * This event is triggered when an error in the Redis backend is thrown.
89
135
  */
90
136
  error: (args: Error) => void;
91
137
  /**
92
138
  * Listen to 'failed' event.
93
139
  *
94
- * This event is triggered when a job has thrown an exception.
140
+ * This event is triggered when a job fails by throwing an exception during execution.
141
+ *
142
+ * @param args - An object containing details about the failed job.
143
+ * @param args.jobId - The unique identifier of the job that failed.
144
+ * @param args.failedReason - The reason or message describing why the job failed.
145
+ * @param args.prev - The previous state of the job before failure (e.g., 'active'), if applicable.
146
+ * @param id - The identifier of the event.
95
147
  */
96
148
  failed: (args: {
97
149
  jobId: string;
@@ -101,16 +153,22 @@ export interface QueueEventsListener extends IoredisListener {
101
153
  /**
102
154
  * Listen to 'paused' event.
103
155
  *
104
- * This event is triggered when a queue is paused.
156
+ * This event is triggered when the queue is paused, halting the processing of new jobs.
157
+ *
158
+ * @param args - An empty object (no additional data provided).
159
+ * @param id - The identifier of the event.
105
160
  */
106
161
  paused: (args: {}, id: string) => void;
107
162
  /**
108
163
  * Listen to 'progress' event.
109
164
  *
110
- * This event is triggered when a job updates it progress, i.e. the
111
- * Job##updateProgress() method is called. This is useful to notify
112
- * progress or any other data from within a processor to the rest of the
113
- * world.
165
+ * This event is triggered when a job updates its progress via the `Job#updateProgress()` method, allowing
166
+ * progress or custom data to be communicated externally.
167
+ *
168
+ * @param args - An object containing the job identifier and progress data.
169
+ * @param args.jobId - The unique identifier of the job reporting progress.
170
+ * @param args.data - The progress data, which can be a number (e.g., percentage) or an object with custom data.
171
+ * @param id - The identifier of the event.
114
172
  */
115
173
  progress: (args: {
116
174
  jobId: string;
@@ -119,8 +177,12 @@ export interface QueueEventsListener extends IoredisListener {
119
177
  /**
120
178
  * Listen to 'removed' event.
121
179
  *
122
- * This event is triggered when a job has been manually
123
- * removed from the queue.
180
+ * This event is triggered when a job is manually removed from the queue.
181
+ *
182
+ * @param args - An object containing details about the removed job.
183
+ * @param args.jobId - The unique identifier of the job that was removed.
184
+ * @param args.prev - The previous state of the job before removal (e.g., 'active' or 'waiting').
185
+ * @param id - The identifier of the event.
124
186
  */
125
187
  removed: (args: {
126
188
  jobId: string;
@@ -129,13 +191,22 @@ export interface QueueEventsListener extends IoredisListener {
129
191
  /**
130
192
  * Listen to 'resumed' event.
131
193
  *
132
- * This event is triggered when a queue is resumed.
194
+ * This event is triggered when the queue is resumed, allowing job processing to continue.
195
+ *
196
+ * @param args - An empty object (no additional data provided).
197
+ * @param id - The identifier of the event.
133
198
  */
134
199
  resumed: (args: {}, id: string) => void;
135
200
  /**
136
201
  * Listen to 'retries-exhausted' event.
137
202
  *
138
- * This event is triggered when a job has retried the maximum attempts.
203
+ * This event is triggered when a job has exhausted its maximum retry attempts after repeated failures.
204
+ *
205
+ * @param args - An object containing details about the job that exhausted retries.
206
+ * @param args.jobId - The unique identifier of the job that exhausted its retries.
207
+ * @param args.attemptsMade - The number of retry attempts made, represented as a string
208
+ * (due to Redis serialization).
209
+ * @param id - The identifier of the event.
139
210
  */
140
211
  'retries-exhausted': (args: {
141
212
  jobId: string;
@@ -144,9 +215,13 @@ export interface QueueEventsListener extends IoredisListener {
144
215
  /**
145
216
  * Listen to 'stalled' event.
146
217
  *
147
- * This event is triggered when a job has been moved from 'active' back
148
- * to 'waiting'/'failed' due to the processor not being able to renew
149
- * the lock on the said job.
218
+ * This event is triggered when a job moves from 'active' back to 'waiting' or
219
+ * 'failed' because the processor could not renew its lock, indicating a
220
+ * potential processing issue.
221
+ *
222
+ * @param args - An object containing the job identifier.
223
+ * @param args.jobId - The unique identifier of the job that stalled.
224
+ * @param id - The identifier of the event.
150
225
  */
151
226
  stalled: (args: {
152
227
  jobId: string;
@@ -154,7 +229,14 @@ export interface QueueEventsListener extends IoredisListener {
154
229
  /**
155
230
  * Listen to 'waiting' event.
156
231
  *
157
- * This event is triggered when a job enters the 'waiting' state.
232
+ * This event is triggered when a job enters the 'waiting' state, indicating it is queued and
233
+ * awaiting processing.
234
+ *
235
+ * @param args - An object containing details about the job in the waiting state.
236
+ * @param args.jobId - The unique identifier of the job that is waiting.
237
+ * @param args.prev - The previous state of the job before entering 'waiting' (e.g., 'stalled'),
238
+ * if applicable.
239
+ * @param id - The identifier of the event.
158
240
  */
159
241
  waiting: (args: {
160
242
  jobId: string;
@@ -163,7 +245,12 @@ export interface QueueEventsListener extends IoredisListener {
163
245
  /**
164
246
  * Listen to 'waiting-children' event.
165
247
  *
166
- * This event is triggered when a job enters the 'waiting-children' state.
248
+ * This event is triggered when a job enters the 'waiting-children' state, indicating it is
249
+ * waiting for its child jobs to complete.
250
+ *
251
+ * @param args - An object containing the job identifier.
252
+ * @param args.jobId - The unique identifier of the job waiting for its children.
253
+ * @param id - The identifier of the event.
167
254
  */
168
255
  'waiting-children': (args: {
169
256
  jobId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../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AC,CAAC;yBAC9D;qBACF;iBACF;aACF;SACF;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;SAClC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
1
+ {"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../../../src/classes/queue-events.ts"],"names":[],"mappings":";AAMA,OAAO,EACL,SAAS,EACT,uBAAuB,EACvB,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAgQzC;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IAGxC,YACE,IAAY,EACZ,KAA8D;QAC5D,UAAU,EAAE,EAAE;KACf,EACD,UAAmC;YAHnC,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,OAE3B,EAFgC,IAAI,cAArC,yBAAuC,CAAF;QAKrC,KAAK,CACH,IAAI,kCAEC,IAAI,KACP,UAAU,EAAE,eAAe,CAAC,UAAU,CAAC;gBACrC,CAAC,CAAe,UAAW,CAAC,SAAS,EAAE;gBACvC,CAAC,CAAC,UAAU,KAEhB,UAAU,EACV,IAAI,CACL,CAAC;QAnBI,YAAO,GAAG,KAAK,CAAC;QAqBtB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CACvB;YACE,eAAe,EAAE,KAAK;SACvB,EACD,IAAI,CAAC,IAAI,CACV,CAAC;QAEF,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;SACtD;IACH,CAAC;IAED,IAAI,CAGF,KAAQ,EAAE,GAAG,IAA8B;QAC3C,OAAO,KAAK,CAAC,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I,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;qBACtB;yBAAM;wBACL,IAAI,CAAC,IAAI,CAAC,KAAY,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;wBACtC,IAAI,QAAQ,CAAC,KAAK,EAAE;4BAClB,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;yBAC9D;qBACF;iBACF;aACF;SACF;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;SAClC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -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
 
43
44
  local nextMillis = ARGV[1]
44
45
  local jobSchedulerId = ARGV[3]
@@ -61,8 +62,35 @@ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
61
62
 
62
63
  if prevMillis ~= false then
63
64
  local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
65
+ local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
64
66
 
65
- if rcall("EXISTS", nextDelayedJobKey) ~= 1 or currentJobId == nextDelayedJobId then
67
+ if rcall("EXISTS", nextDelayedJobKey) == 1 then
68
+ if rcall("ZSCORE", delayedKey, nextDelayedJobId) ~= false then
69
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
70
+ rcall("ZREM", delayedKey, nextDelayedJobId)
71
+ elseif rcall("ZSCORE", prioritizedKey, nextDelayedJobId) ~= false then
72
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
73
+ rcall("ZREM", prioritizedKey, nextDelayedJobId)
74
+ else
75
+ local pausedOrWaitKey = waitKey
76
+ if isQueuePaused(metaKey) then
77
+ pausedOrWaitKey = pausedKey
78
+ end
79
+
80
+ if rcall("LREM", pausedOrWaitKey, 1, nextDelayedJobId) > 0 then
81
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
82
+ else
83
+ local maxEvents = getOrSetMaxEvents(metaKey)
84
+
85
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
86
+ "duplicated", "jobId", nextDelayedJobId)
87
+
88
+ return nextDelayedJobId .. "" -- convert to string
89
+ end
90
+ end
91
+ end
92
+
93
+ if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
66
94
  if rcall("ZSCORE", delayedKey, currentJobId) ~= false then
67
95
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
68
96
  rcall("ZREM", delayedKey, currentJobId)
@@ -70,14 +98,13 @@ if prevMillis ~= false then
70
98
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
71
99
  rcall("ZREM", prioritizedKey, currentJobId)
72
100
  else
101
+ local pausedOrWaitKey = waitKey
73
102
  if isQueuePaused(metaKey) then
74
- if rcall("LREM", pausedKey, 1, currentJobId) > 0 then
75
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
76
- end
77
- else
78
- if rcall("LREM", waitKey, 1, currentJobId) > 0 then
79
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
80
- end
103
+ pausedOrWaitKey = pausedKey
104
+ end
105
+
106
+ if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
107
+ removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
81
108
  end
82
109
  end
83
110
  end
@@ -86,19 +113,16 @@ end
86
113
  local schedulerOpts = cmsgpack.unpack(ARGV[2])
87
114
  storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
88
115
 
89
- if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
90
- local eventsKey = KEYS[9]
91
- local maxEvents = getOrSetMaxEvents(metaKey)
92
-
93
- rcall("INCR", KEYS[8])
116
+ rcall("INCR", KEYS[8])
94
117
 
95
- addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
96
- KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
97
- schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
118
+ local maxEvents = getOrSetMaxEvents(metaKey)
98
119
 
99
- if ARGV[9] ~= "" then
100
- rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
101
- end
120
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
121
+ KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
122
+ schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
102
123
 
103
- return nextDelayedJobId .. "" -- convert to string
124
+ if ARGV[9] ~= "" then
125
+ rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
104
126
  end
127
+
128
+ return nextDelayedJobId .. "" -- convert to string
@@ -1,24 +1,23 @@
1
1
  --[[
2
2
  Function to debounce a job.
3
- ]]
4
-
3
+ ]]
5
4
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
6
5
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
7
6
  if deduplicationId then
8
- local ttl = deduplicationOpts['ttl']
9
- local deduplicationKeyExists
10
- if ttl then
11
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
12
- else
13
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
14
- end
15
- if deduplicationKeyExists then
16
- local currentDebounceJobId = rcall('GET', deduplicationKey)
17
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
18
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
19
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
20
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
21
- return currentDebounceJobId
22
- end
7
+ local ttl = deduplicationOpts['ttl']
8
+ local deduplicationKeyExists
9
+ if ttl then
10
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
11
+ else
12
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
13
+ end
14
+ if deduplicationKeyExists then
15
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
16
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
17
+ "debounceId", deduplicationId)
18
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
19
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
20
+ return currentDebounceJobId
21
+ end
23
22
  end
24
23
  end
@@ -111,25 +111,25 @@ local function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,
111
111
  end
112
112
  --[[
113
113
  Function to debounce a job.
114
- ]]
114
+ ]]
115
115
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
116
116
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
117
117
  if deduplicationId then
118
- local ttl = deduplicationOpts['ttl']
119
- local deduplicationKeyExists
120
- if ttl then
121
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
122
- else
123
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
124
- end
125
- if deduplicationKeyExists then
126
- local currentDebounceJobId = rcall('GET', deduplicationKey)
127
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
128
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
129
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
130
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
131
- return currentDebounceJobId
132
- end
118
+ local ttl = deduplicationOpts['ttl']
119
+ local deduplicationKeyExists
120
+ if ttl then
121
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
122
+ else
123
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
124
+ end
125
+ if deduplicationKeyExists then
126
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
127
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
128
+ "debounceId", deduplicationId)
129
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
130
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
131
+ return currentDebounceJobId
132
+ end
133
133
  end
134
134
  end
135
135
  --[[
@@ -36,6 +36,7 @@ local waitKey = KEYS[3]
36
36
  local pausedKey = KEYS[4]
37
37
  local metaKey = KEYS[5]
38
38
  local prioritizedKey = KEYS[6]
39
+ local eventsKey = KEYS[9]
39
40
  local nextMillis = ARGV[1]
40
41
  local jobSchedulerId = ARGV[3]
41
42
  local templateOpts = cmsgpack.unpack(ARGV[5])
@@ -395,7 +396,30 @@ local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
395
396
  local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
396
397
  if prevMillis ~= false then
397
398
  local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
398
- if rcall("EXISTS", nextDelayedJobKey) ~= 1 or currentJobId == nextDelayedJobId then
399
+ local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
400
+ if rcall("EXISTS", nextDelayedJobKey) == 1 then
401
+ if rcall("ZSCORE", delayedKey, nextDelayedJobId) ~= false then
402
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
403
+ rcall("ZREM", delayedKey, nextDelayedJobId)
404
+ elseif rcall("ZSCORE", prioritizedKey, nextDelayedJobId) ~= false then
405
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
406
+ rcall("ZREM", prioritizedKey, nextDelayedJobId)
407
+ else
408
+ local pausedOrWaitKey = waitKey
409
+ if isQueuePaused(metaKey) then
410
+ pausedOrWaitKey = pausedKey
411
+ end
412
+ if rcall("LREM", pausedOrWaitKey, 1, nextDelayedJobId) > 0 then
413
+ removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
414
+ else
415
+ local maxEvents = getOrSetMaxEvents(metaKey)
416
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
417
+ "duplicated", "jobId", nextDelayedJobId)
418
+ return nextDelayedJobId .. "" -- convert to string
419
+ end
420
+ end
421
+ end
422
+ if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
399
423
  if rcall("ZSCORE", delayedKey, currentJobId) ~= false then
400
424
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
401
425
  rcall("ZREM", delayedKey, currentJobId)
@@ -403,32 +427,27 @@ if prevMillis ~= false then
403
427
  removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
404
428
  rcall("ZREM", prioritizedKey, currentJobId)
405
429
  else
430
+ local pausedOrWaitKey = waitKey
406
431
  if isQueuePaused(metaKey) then
407
- if rcall("LREM", pausedKey, 1, currentJobId) > 0 then
408
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
409
- end
410
- else
411
- if rcall("LREM", waitKey, 1, currentJobId) > 0 then
412
- removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
413
- end
432
+ pausedOrWaitKey = pausedKey
433
+ end
434
+ if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
435
+ removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
414
436
  end
415
437
  end
416
438
  end
417
439
  end
418
440
  local schedulerOpts = cmsgpack.unpack(ARGV[2])
419
441
  storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
420
- if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
421
- local eventsKey = KEYS[9]
422
- local maxEvents = getOrSetMaxEvents(metaKey)
423
- rcall("INCR", KEYS[8])
424
- addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
425
- KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
426
- schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
427
- if ARGV[9] ~= "" then
428
- rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
429
- end
430
- return nextDelayedJobId .. "" -- convert to string
442
+ rcall("INCR", KEYS[8])
443
+ local maxEvents = getOrSetMaxEvents(metaKey)
444
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
445
+ KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
446
+ schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
447
+ if ARGV[9] ~= "" then
448
+ rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
431
449
  end
450
+ return nextDelayedJobId .. "" -- convert to string
432
451
  `;
433
452
  export const addJobScheduler = {
434
453
  name: 'addJobScheduler',
@@ -1 +1 @@
1
- {"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -43,25 +43,25 @@ local parentData
43
43
  -- Includes
44
44
  --[[
45
45
  Function to debounce a job.
46
- ]]
46
+ ]]
47
47
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
48
48
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
49
49
  if deduplicationId then
50
- local ttl = deduplicationOpts['ttl']
51
- local deduplicationKeyExists
52
- if ttl then
53
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
54
- else
55
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
56
- end
57
- if deduplicationKeyExists then
58
- local currentDebounceJobId = rcall('GET', deduplicationKey)
59
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
60
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
61
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
62
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
63
- return currentDebounceJobId
64
- end
50
+ local ttl = deduplicationOpts['ttl']
51
+ local deduplicationKeyExists
52
+ if ttl then
53
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
54
+ else
55
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
56
+ end
57
+ if deduplicationKeyExists then
58
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
59
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
60
+ "debounceId", deduplicationId)
61
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
62
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
63
+ return currentDebounceJobId
64
+ end
65
65
  end
66
66
  end
67
67
  --[[
@@ -75,25 +75,25 @@ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, pr
75
75
  end
76
76
  --[[
77
77
  Function to debounce a job.
78
- ]]
78
+ ]]
79
79
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
80
80
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
81
81
  if deduplicationId then
82
- local ttl = deduplicationOpts['ttl']
83
- local deduplicationKeyExists
84
- if ttl then
85
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
86
- else
87
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
88
- end
89
- if deduplicationKeyExists then
90
- local currentDebounceJobId = rcall('GET', deduplicationKey)
91
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
92
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
93
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
94
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
95
- return currentDebounceJobId
96
- end
82
+ local ttl = deduplicationOpts['ttl']
83
+ local deduplicationKeyExists
84
+ if ttl then
85
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
86
+ else
87
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
88
+ end
89
+ if deduplicationKeyExists then
90
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
91
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
92
+ "debounceId", deduplicationId)
93
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
94
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
95
+ return currentDebounceJobId
96
+ end
97
97
  end
98
98
  end
99
99
  --[[