bullmq 5.40.1 → 5.40.3

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 (54) hide show
  1. package/dist/cjs/classes/job-scheduler.js +4 -1
  2. package/dist/cjs/classes/job-scheduler.js.map +1 -1
  3. package/dist/cjs/commands/addDelayedJob-6.lua +2 -2
  4. package/dist/cjs/commands/addJobScheduler-2.lua +5 -41
  5. package/dist/cjs/commands/addParentJob-4.lua +2 -2
  6. package/dist/cjs/commands/addPrioritizedJob-8.lua +2 -2
  7. package/dist/cjs/commands/addStandardJob-8.lua +2 -2
  8. package/dist/cjs/commands/includes/deduplicateJob.lua +1 -1
  9. package/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +1 -1
  10. package/dist/cjs/commands/includes/storeJobScheduler.lua +41 -0
  11. package/dist/cjs/scripts/addDelayedJob-6.js +4 -4
  12. package/dist/cjs/scripts/addJobScheduler-2.js +37 -32
  13. package/dist/cjs/scripts/addJobScheduler-2.js.map +1 -1
  14. package/dist/cjs/scripts/addParentJob-4.js +4 -4
  15. package/dist/cjs/scripts/addPrioritizedJob-8.js +4 -4
  16. package/dist/cjs/scripts/addStandardJob-8.js +4 -4
  17. package/dist/cjs/scripts/changeDelay-4.js +1 -1
  18. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +1 -1
  19. package/dist/cjs/scripts/moveToActive-11.js +1 -1
  20. package/dist/cjs/scripts/moveToDelayed-8.js +1 -1
  21. package/dist/cjs/scripts/moveToFinished-14.js +1 -1
  22. package/dist/cjs/scripts/pause-7.js +1 -1
  23. package/dist/cjs/scripts/updateJobScheduler-7.js +1 -1
  24. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  25. package/dist/cjs/version.js +1 -1
  26. package/dist/esm/classes/job-scheduler.d.ts +1 -1
  27. package/dist/esm/classes/job-scheduler.js +4 -1
  28. package/dist/esm/classes/job-scheduler.js.map +1 -1
  29. package/dist/esm/classes/queue.d.ts +1 -1
  30. package/dist/esm/commands/addDelayedJob-6.lua +2 -2
  31. package/dist/esm/commands/addJobScheduler-2.lua +5 -41
  32. package/dist/esm/commands/addParentJob-4.lua +2 -2
  33. package/dist/esm/commands/addPrioritizedJob-8.lua +2 -2
  34. package/dist/esm/commands/addStandardJob-8.lua +2 -2
  35. package/dist/esm/commands/includes/deduplicateJob.lua +1 -1
  36. package/dist/esm/commands/includes/getNextDelayedTimestamp.lua +1 -1
  37. package/dist/esm/commands/includes/storeJobScheduler.lua +41 -0
  38. package/dist/esm/scripts/addDelayedJob-6.js +4 -4
  39. package/dist/esm/scripts/addJobScheduler-2.js +37 -32
  40. package/dist/esm/scripts/addJobScheduler-2.js.map +1 -1
  41. package/dist/esm/scripts/addParentJob-4.js +4 -4
  42. package/dist/esm/scripts/addPrioritizedJob-8.js +4 -4
  43. package/dist/esm/scripts/addStandardJob-8.js +4 -4
  44. package/dist/esm/scripts/changeDelay-4.js +1 -1
  45. package/dist/esm/scripts/moveStalledJobsToWait-9.js +1 -1
  46. package/dist/esm/scripts/moveToActive-11.js +1 -1
  47. package/dist/esm/scripts/moveToDelayed-8.js +1 -1
  48. package/dist/esm/scripts/moveToFinished-14.js +1 -1
  49. package/dist/esm/scripts/pause-7.js +1 -1
  50. package/dist/esm/scripts/updateJobScheduler-7.js +1 -1
  51. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  52. package/dist/esm/version.d.ts +1 -1
  53. package/dist/esm/version.js +1 -1
  54. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ --[[
2
+ Function to store a job scheduler
3
+ ]]
4
+ local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMillis, opts,
5
+ templateData, templateOpts)
6
+ rcall("ZADD", repeatKey, nextMillis, schedulerId)
7
+
8
+ local optionalValues = {}
9
+ if opts['tz'] then
10
+ table.insert(optionalValues, "tz")
11
+ table.insert(optionalValues, opts['tz'])
12
+ end
13
+
14
+ if opts['pattern'] then
15
+ table.insert(optionalValues, "pattern")
16
+ table.insert(optionalValues, opts['pattern'])
17
+ end
18
+
19
+ if opts['endDate'] then
20
+ table.insert(optionalValues, "endDate")
21
+ table.insert(optionalValues, opts['endDate'])
22
+ end
23
+
24
+ if opts['every'] then
25
+ table.insert(optionalValues, "every")
26
+ table.insert(optionalValues, opts['every'])
27
+ end
28
+
29
+ local jsonTemplateOpts = cjson.encode(templateOpts)
30
+ if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then
31
+ table.insert(optionalValues, "opts")
32
+ table.insert(optionalValues, jsonTemplateOpts)
33
+ end
34
+
35
+ if templateData and templateData ~= '{}' then
36
+ table.insert(optionalValues, "data")
37
+ table.insert(optionalValues, templateData)
38
+ end
39
+
40
+ rcall("HMSET", schedulerKey, "name", opts['name'], unpack(optionalValues))
41
+ end
@@ -63,7 +63,7 @@ local function getNextDelayedTimestamp(delayedKey)
63
63
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
64
64
  if #result then
65
65
  local nextTimestamp = tonumber(result[2])
66
- if nextTimestamp ~= nil then
66
+ if nextTimestamp ~= nil then
67
67
  return nextTimestamp / 0x1000
68
68
  end
69
69
  end
@@ -145,7 +145,7 @@ end
145
145
  --[[
146
146
  Function to debounce a job.
147
147
  ]]
148
- local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
148
+ local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
149
149
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
150
150
  if deduplicationId then
151
151
  local ttl = deduplicationOpts['ttl']
@@ -359,8 +359,8 @@ else
359
359
  maxEvents, timestamp)
360
360
  end
361
361
  end
362
- local deduplicationJobId = deduplicateJob(args[1], opts['de'],
363
- jobId, deduplicationKey, eventsKey, maxEvents)
362
+ local deduplicationJobId = deduplicateJob(opts['de'], jobId, deduplicationKey,
363
+ eventsKey, maxEvents)
364
364
  if deduplicationJobId then
365
365
  return deduplicationJobId
366
366
  end
@@ -177,51 +177,56 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
177
177
  end
178
178
  removeJobKeys(jobKey)
179
179
  end
180
- local function storeRepeatableJob(schedulerId, repeatKey, nextMillis, rawOpts, templateData, templateOpts)
181
- rcall("ZADD", repeatKey, nextMillis, schedulerId)
182
- local opts = cmsgpack.unpack(rawOpts)
183
- local optionalValues = {}
184
- if opts['tz'] then
185
- table.insert(optionalValues, "tz")
186
- table.insert(optionalValues, opts['tz'])
187
- end
188
- if opts['pattern'] then
189
- table.insert(optionalValues, "pattern")
190
- table.insert(optionalValues, opts['pattern'])
191
- end
192
- if opts['endDate'] then
193
- table.insert(optionalValues, "endDate")
194
- table.insert(optionalValues, opts['endDate'])
195
- end
196
- if opts['every'] then
197
- table.insert(optionalValues, "every")
198
- table.insert(optionalValues, opts['every'])
199
- end
200
- local jsonTemplateOpts = cjson.encode(templateOpts)
201
- if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then
202
- table.insert(optionalValues, "opts")
203
- table.insert(optionalValues, jsonTemplateOpts)
204
- end
205
- if templateData and templateData ~= '{}' then
206
- table.insert(optionalValues, "data")
207
- table.insert(optionalValues, templateData)
208
- end
209
- rcall("HMSET", repeatKey .. ":" .. schedulerId, "name", opts['name'], unpack(optionalValues))
180
+ --[[
181
+ Function to store a job scheduler
182
+ ]]
183
+ local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMillis, opts,
184
+ templateData, templateOpts)
185
+ rcall("ZADD", repeatKey, nextMillis, schedulerId)
186
+ local optionalValues = {}
187
+ if opts['tz'] then
188
+ table.insert(optionalValues, "tz")
189
+ table.insert(optionalValues, opts['tz'])
190
+ end
191
+ if opts['pattern'] then
192
+ table.insert(optionalValues, "pattern")
193
+ table.insert(optionalValues, opts['pattern'])
194
+ end
195
+ if opts['endDate'] then
196
+ table.insert(optionalValues, "endDate")
197
+ table.insert(optionalValues, opts['endDate'])
198
+ end
199
+ if opts['every'] then
200
+ table.insert(optionalValues, "every")
201
+ table.insert(optionalValues, opts['every'])
202
+ end
203
+ local jsonTemplateOpts = cjson.encode(templateOpts)
204
+ if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then
205
+ table.insert(optionalValues, "opts")
206
+ table.insert(optionalValues, jsonTemplateOpts)
207
+ end
208
+ if templateData and templateData ~= '{}' then
209
+ table.insert(optionalValues, "data")
210
+ table.insert(optionalValues, templateData)
211
+ end
212
+ rcall("HMSET", schedulerKey, "name", opts['name'], unpack(optionalValues))
210
213
  end
211
214
  -- If we are overriding a repeatable job we must delete the delayed job for
212
215
  -- the next iteration.
216
+ local schedulerKey = repeatKey .. ":" .. jobSchedulerId
213
217
  local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
214
218
  if prevMillis ~= false then
215
219
  local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
216
220
  local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
217
- local nextDelayedJobKey = repeatKey .. ":" .. jobSchedulerId .. ":" .. nextMillis
221
+ local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
218
222
  if rcall("ZSCORE", delayedKey, delayedJobId) ~= false and
219
223
  (rcall("EXISTS", nextDelayedJobKey) ~= 1 or delayedJobId == nextDelayedJobId) then
220
224
  removeJob(delayedJobId, true, prefixKey, true --[[remove debounce key]] )
221
225
  rcall("ZREM", delayedKey, delayedJobId)
222
226
  end
223
227
  end
224
- return storeRepeatableJob(jobSchedulerId, repeatKey, nextMillis, ARGV[2], ARGV[4], templateOpts)
228
+ local schedulerOpts = cmsgpack.unpack(ARGV[2])
229
+ return storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
225
230
  `;
226
231
  export const addJobScheduler = {
227
232
  name: 'addJobScheduler',
@@ -1 +1 @@
1
- {"version":3,"file":"addJobScheduler-2.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgOf,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addJobScheduler-2.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqOf,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -44,7 +44,7 @@ local parentData
44
44
  --[[
45
45
  Function to debounce a job.
46
46
  ]]
47
- local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
47
+ local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
48
48
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
49
49
  if deduplicationId then
50
50
  local ttl = deduplicationOpts['ttl']
@@ -105,7 +105,7 @@ local function getNextDelayedTimestamp(delayedKey)
105
105
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
106
106
  if #result then
107
107
  local nextTimestamp = tonumber(result[2])
108
- if nextTimestamp ~= nil then
108
+ if nextTimestamp ~= nil then
109
109
  return nextTimestamp / 0x1000
110
110
  end
111
111
  end
@@ -311,8 +311,8 @@ else
311
311
  maxEvents, timestamp)
312
312
  end
313
313
  end
314
- local deduplicationJobId = deduplicateJob(args[1], opts['de'],
315
- jobId, deduplicationKey, eventsKey, maxEvents)
314
+ local deduplicationJobId = deduplicateJob(opts['de'], jobId,
315
+ deduplicationKey, eventsKey, maxEvents)
316
316
  if deduplicationJobId then
317
317
  return deduplicationJobId
318
318
  end
@@ -70,7 +70,7 @@ end
70
70
  --[[
71
71
  Function to debounce a job.
72
72
  ]]
73
- local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
73
+ local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
74
74
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
75
75
  if deduplicationId then
76
76
  local ttl = deduplicationOpts['ttl']
@@ -161,7 +161,7 @@ local function getNextDelayedTimestamp(delayedKey)
161
161
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
162
162
  if #result then
163
163
  local nextTimestamp = tonumber(result[2])
164
- if nextTimestamp ~= nil then
164
+ if nextTimestamp ~= nil then
165
165
  return nextTimestamp / 0x1000
166
166
  end
167
167
  end
@@ -318,8 +318,8 @@ else
318
318
  maxEvents, timestamp)
319
319
  end
320
320
  end
321
- local deduplicationJobId = deduplicateJob(args[1], opts['de'],
322
- jobId, deduplicationKey, eventsKey, maxEvents)
321
+ local deduplicationJobId = deduplicateJob(opts['de'], jobId,
322
+ deduplicationKey, eventsKey, maxEvents)
323
323
  if deduplicationJobId then
324
324
  return deduplicationJobId
325
325
  end
@@ -70,7 +70,7 @@ end
70
70
  --[[
71
71
  Function to debounce a job.
72
72
  ]]
73
- local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
73
+ local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
74
74
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
75
75
  if deduplicationId then
76
76
  local ttl = deduplicationOpts['ttl']
@@ -151,7 +151,7 @@ local function getNextDelayedTimestamp(delayedKey)
151
151
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
152
152
  if #result then
153
153
  local nextTimestamp = tonumber(result[2])
154
- if nextTimestamp ~= nil then
154
+ if nextTimestamp ~= nil then
155
155
  return nextTimestamp / 0x1000
156
156
  end
157
157
  end
@@ -322,8 +322,8 @@ else
322
322
  maxEvents, timestamp)
323
323
  end
324
324
  end
325
- local deduplicationJobId = deduplicateJob(args[1], opts['de'],
326
- jobId, deduplicationKey, eventsKey, maxEvents)
325
+ local deduplicationJobId = deduplicateJob(opts['de'], jobId,
326
+ deduplicationKey, eventsKey, maxEvents)
327
327
  if deduplicationJobId then
328
328
  return deduplicationJobId
329
329
  end
@@ -29,7 +29,7 @@ local function getNextDelayedTimestamp(delayedKey)
29
29
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
30
30
  if #result then
31
31
  local nextTimestamp = tonumber(result[2])
32
- if nextTimestamp ~= nil then
32
+ if nextTimestamp ~= nil then
33
33
  return nextTimestamp / 0x1000
34
34
  end
35
35
  end
@@ -90,7 +90,7 @@ local function getNextDelayedTimestamp(delayedKey)
90
90
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
91
91
  if #result then
92
92
  local nextTimestamp = tonumber(result[2])
93
- if nextTimestamp ~= nil then
93
+ if nextTimestamp ~= nil then
94
94
  return nextTimestamp / 0x1000
95
95
  end
96
96
  end
@@ -42,7 +42,7 @@ local function getNextDelayedTimestamp(delayedKey)
42
42
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
43
43
  if #result then
44
44
  local nextTimestamp = tonumber(result[2])
45
- if nextTimestamp ~= nil then
45
+ if nextTimestamp ~= nil then
46
46
  return nextTimestamp / 0x1000
47
47
  end
48
48
  end
@@ -36,7 +36,7 @@ local function getNextDelayedTimestamp(delayedKey)
36
36
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
37
37
  if #result then
38
38
  local nextTimestamp = tonumber(result[2])
39
- if nextTimestamp ~= nil then
39
+ if nextTimestamp ~= nil then
40
40
  return nextTimestamp / 0x1000
41
41
  end
42
42
  end
@@ -109,7 +109,7 @@ local function getNextDelayedTimestamp(delayedKey)
109
109
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
110
110
  if #result then
111
111
  local nextTimestamp = tonumber(result[2])
112
- if nextTimestamp ~= nil then
112
+ if nextTimestamp ~= nil then
113
113
  return nextTimestamp / 0x1000
114
114
  end
115
115
  end
@@ -25,7 +25,7 @@ local function getNextDelayedTimestamp(delayedKey)
25
25
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
26
26
  if #result then
27
27
  local nextTimestamp = tonumber(result[2])
28
- if nextTimestamp ~= nil then
28
+ if nextTimestamp ~= nil then
29
29
  return nextTimestamp / 0x1000
30
30
  end
31
31
  end
@@ -45,7 +45,7 @@ local function getNextDelayedTimestamp(delayedKey)
45
45
  local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
46
46
  if #result then
47
47
  local nextTimestamp = tonumber(result[2])
48
- if nextTimestamp ~= nil then
48
+ if nextTimestamp ~= nil then
49
49
  return nextTimestamp / 0x1000
50
50
  end
51
51
  end