bullmq 5.44.4 → 5.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/commands/includes/deduplicateJob.lua +16 -17
- package/dist/cjs/commands/updateJobScheduler-12.lua +28 -22
- package/dist/cjs/scripts/addDelayedJob-6.js +16 -16
- package/dist/cjs/scripts/addParentJob-4.js +16 -16
- package/dist/cjs/scripts/addPrioritizedJob-8.js +16 -16
- package/dist/cjs/scripts/addStandardJob-8.js +16 -16
- package/dist/cjs/scripts/updateJobScheduler-12.js +25 -19
- package/dist/cjs/scripts/updateJobScheduler-12.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/queue-events.d.ts +113 -26
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/commands/includes/deduplicateJob.lua +16 -17
- package/dist/esm/commands/updateJobScheduler-12.lua +28 -22
- package/dist/esm/scripts/addDelayedJob-6.js +16 -16
- package/dist/esm/scripts/addParentJob-4.js +16 -16
- package/dist/esm/scripts/addPrioritizedJob-8.js +16 -16
- package/dist/esm/scripts/addStandardJob-8.js +16 -16
- package/dist/esm/scripts/updateJobScheduler-12.js +25 -19
- package/dist/esm/scripts/updateJobScheduler-12.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +21 -16
@@ -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
|
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
|
-
*
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
111
|
-
*
|
112
|
-
*
|
113
|
-
*
|
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
|
123
|
-
*
|
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
|
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
|
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
|
148
|
-
*
|
149
|
-
*
|
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":["../../../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;
|
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,E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AS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAErC,EAAE;oBACF,gEAAgE;oBAChE,sBAAsB;oBACtB,QAAQ,IAAI,CAAC,KAAK,EAAE;wBAClB,KAAK,UAAU;4BACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;4BAClC,MAAM;wBACR,KAAK,WAAW;4BACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;4BAChD,MAAM;qBACT;oBAED,MAAM,EAAE,KAAK,KAAkB,IAAI,EAAjB,QAAQ,UAAK,IAAI,EAA7B,SAAsB,CAAO,CAAC;oBAEpC,IAAI,KAAK,KAAK,SAAS,EAAE;wBACvB,IAAI,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"}
|
@@ -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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
@@ -25,7 +25,8 @@
|
|
25
25
|
|
26
26
|
Output:
|
27
27
|
next delayed job id - OK
|
28
|
-
]]
|
28
|
+
]]
|
29
|
+
local rcall = redis.call
|
29
30
|
local repeatKey = KEYS[1]
|
30
31
|
local delayedKey = KEYS[2]
|
31
32
|
local waitKey = KEYS[3]
|
@@ -51,34 +52,39 @@ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
|
51
52
|
if prevMillis ~= false then
|
52
53
|
local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
53
54
|
|
54
|
-
if producerId == currentDelayedJobId
|
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("
|
59
|
+
if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
|
60
|
+
local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
local templateData = schedulerAttributes[2] or ARGV[3]
|
62
|
+
rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
|
63
|
+
rcall("HINCRBY", schedulerKey, "ic", 1)
|
68
64
|
|
69
|
-
|
70
|
-
rcall("HSET", schedulerKey, "data", templateData)
|
71
|
-
end
|
65
|
+
rcall("INCR", KEYS[8])
|
72
66
|
|
73
|
-
|
74
|
-
|
75
|
-
schedulerAttributes[
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
71
|
+
if templateData and templateData ~= '{}' then
|
72
|
+
rcall("HSET", schedulerKey, "data", templateData)
|
73
|
+
end
|
81
74
|
|
82
|
-
|
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
|
@@ -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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
--[[
|
@@ -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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
--[[
|
@@ -69,25 +69,25 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
|
|
69
69
|
end
|
70
70
|
--[[
|
71
71
|
Function to debounce a job.
|
72
|
-
]]
|
72
|
+
]]
|
73
73
|
local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
|
74
74
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
75
75
|
if deduplicationId then
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
76
|
+
local ttl = deduplicationOpts['ttl']
|
77
|
+
local deduplicationKeyExists
|
78
|
+
if ttl then
|
79
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
80
|
+
else
|
81
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
82
|
+
end
|
83
|
+
if deduplicationKeyExists then
|
84
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
85
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
|
86
|
+
"debounceId", deduplicationId)
|
87
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
88
|
+
currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
89
|
+
return currentDebounceJobId
|
90
|
+
end
|
91
91
|
end
|
92
92
|
end
|
93
93
|
--[[
|
@@ -22,7 +22,8 @@ const content = `--[[
|
|
22
22
|
ARGV[7] producer id
|
23
23
|
Output:
|
24
24
|
next delayed job id - OK
|
25
|
-
]]
|
25
|
+
]]
|
26
|
+
local rcall = redis.call
|
26
27
|
local repeatKey = KEYS[1]
|
27
28
|
local delayedKey = KEYS[2]
|
28
29
|
local waitKey = KEYS[3]
|
@@ -233,27 +234,32 @@ local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
|
|
233
234
|
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
234
235
|
if prevMillis ~= false then
|
235
236
|
local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
236
|
-
if producerId == currentDelayedJobId
|
237
|
-
local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
|
238
|
-
rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
|
239
|
-
rcall("HINCRBY", schedulerKey, "ic", 1)
|
237
|
+
if producerId == currentDelayedJobId then
|
240
238
|
local eventsKey = KEYS[9]
|
241
239
|
local maxEvents = getOrSetMaxEvents(metaKey)
|
242
|
-
rcall("
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
240
|
+
if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
|
241
|
+
local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
|
242
|
+
rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
|
243
|
+
rcall("HINCRBY", schedulerKey, "ic", 1)
|
244
|
+
rcall("INCR", KEYS[8])
|
245
|
+
-- TODO: remove this workaround in next breaking change,
|
246
|
+
-- all job-schedulers must save job data
|
247
|
+
local templateData = schedulerAttributes[2] or ARGV[3]
|
248
|
+
if templateData and templateData ~= '{}' then
|
249
|
+
rcall("HSET", schedulerKey, "data", templateData)
|
250
|
+
end
|
251
|
+
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
|
252
|
+
KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
253
|
+
schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
|
254
|
+
-- TODO: remove this workaround in next breaking change
|
255
|
+
if KEYS[11] ~= "" then
|
256
|
+
rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
|
257
|
+
end
|
258
|
+
return nextDelayedJobId .. "" -- convert to string
|
259
|
+
else
|
260
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
261
|
+
"duplicated", "jobId", nextDelayedJobId)
|
255
262
|
end
|
256
|
-
return nextDelayedJobId .. "" -- convert to string
|
257
263
|
end
|
258
264
|
end
|
259
265
|
`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"updateJobScheduler-12.js","sourceRoot":"","sources":["../../../src/scripts/updateJobScheduler-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"updateJobScheduler-12.js","sourceRoot":"","sources":["../../../src/scripts/updateJobScheduler-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwQf,CAAC;AACF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,oBAAoB;IAC1B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|