bullmq 5.15.0 → 5.17.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 (150) hide show
  1. package/dist/cjs/classes/child-pool.js +2 -2
  2. package/dist/cjs/classes/child-pool.js.map +1 -1
  3. package/dist/cjs/classes/job-scheduler.js +140 -0
  4. package/dist/cjs/classes/job-scheduler.js.map +1 -0
  5. package/dist/cjs/classes/job.js +6 -2
  6. package/dist/cjs/classes/job.js.map +1 -1
  7. package/dist/cjs/classes/queue-events.js.map +1 -1
  8. package/dist/cjs/classes/queue-getters.js +10 -0
  9. package/dist/cjs/classes/queue-getters.js.map +1 -1
  10. package/dist/cjs/classes/queue-keys.js +1 -1
  11. package/dist/cjs/classes/queue-keys.js.map +1 -1
  12. package/dist/cjs/classes/queue.js +74 -0
  13. package/dist/cjs/classes/queue.js.map +1 -1
  14. package/dist/cjs/classes/repeat.js +9 -10
  15. package/dist/cjs/classes/repeat.js.map +1 -1
  16. package/dist/cjs/classes/sandbox.js +57 -47
  17. package/dist/cjs/classes/sandbox.js.map +1 -1
  18. package/dist/cjs/classes/scripts.js +46 -40
  19. package/dist/cjs/classes/scripts.js.map +1 -1
  20. package/dist/cjs/classes/worker.js +23 -4
  21. package/dist/cjs/classes/worker.js.map +1 -1
  22. package/dist/cjs/commands/addDelayedJob-6.lua +7 -7
  23. package/dist/cjs/commands/addJobScheduler-2.lua +75 -0
  24. package/dist/cjs/commands/addParentJob-4.lua +7 -7
  25. package/dist/cjs/commands/addPrioritizedJob-8.lua +7 -7
  26. package/dist/cjs/commands/addStandardJob-8.lua +7 -7
  27. package/dist/cjs/commands/{cleanJobsInSet-2.lua → cleanJobsInSet-3.lua} +6 -5
  28. package/dist/cjs/commands/drain-5.lua +41 -0
  29. package/dist/cjs/commands/includes/cleanSet.lua +50 -29
  30. package/dist/cjs/commands/includes/deduplicateJob.lua +25 -0
  31. package/dist/cjs/commands/includes/removeZSetJobs.lua +13 -1
  32. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +2 -4
  33. package/dist/cjs/commands/removeJob-2.lua +17 -9
  34. package/dist/cjs/commands/removeJobScheduler-3.lua +43 -0
  35. package/dist/cjs/enums/error-code.js +1 -0
  36. package/dist/cjs/enums/error-code.js.map +1 -1
  37. package/dist/cjs/scripts/addDelayedJob-6.js +18 -16
  38. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  39. package/dist/cjs/scripts/addJobScheduler-2.js +223 -0
  40. package/dist/cjs/scripts/addJobScheduler-2.js.map +1 -0
  41. package/dist/cjs/scripts/addParentJob-4.js +18 -16
  42. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  43. package/dist/cjs/scripts/addPrioritizedJob-8.js +18 -16
  44. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
  45. package/dist/cjs/scripts/addStandardJob-8.js +18 -16
  46. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
  47. package/dist/cjs/scripts/{cleanJobsInSet-2.js → cleanJobsInSet-3.js} +57 -35
  48. package/dist/cjs/scripts/{cleanJobsInSet-2.js.map → cleanJobsInSet-3.js.map} +1 -1
  49. package/dist/cjs/scripts/{drain-4.js → drain-5.js} +28 -7
  50. package/dist/cjs/scripts/drain-5.js.map +1 -0
  51. package/dist/cjs/scripts/index.js +4 -2
  52. package/dist/cjs/scripts/index.js.map +1 -1
  53. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +2 -3
  54. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  55. package/dist/cjs/scripts/obliterate-2.js +11 -1
  56. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  57. package/dist/cjs/scripts/removeJob-2.js +16 -9
  58. package/dist/cjs/scripts/removeJob-2.js.map +1 -1
  59. package/dist/cjs/scripts/removeJobScheduler-3.js +49 -0
  60. package/dist/cjs/scripts/removeJobScheduler-3.js.map +1 -0
  61. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  62. package/dist/cjs/utils.js +25 -1
  63. package/dist/cjs/utils.js.map +1 -1
  64. package/dist/esm/classes/child-pool.d.ts +1 -1
  65. package/dist/esm/classes/child-pool.js +2 -2
  66. package/dist/esm/classes/child-pool.js.map +1 -1
  67. package/dist/esm/classes/job-scheduler.d.ts +30 -0
  68. package/dist/esm/classes/job-scheduler.js +135 -0
  69. package/dist/esm/classes/job-scheduler.js.map +1 -0
  70. package/dist/esm/classes/job.d.ts +6 -1
  71. package/dist/esm/classes/job.js +7 -3
  72. package/dist/esm/classes/job.js.map +1 -1
  73. package/dist/esm/classes/queue-events.d.ts +10 -0
  74. package/dist/esm/classes/queue-events.js.map +1 -1
  75. package/dist/esm/classes/queue-getters.d.ts +7 -0
  76. package/dist/esm/classes/queue-getters.js +10 -0
  77. package/dist/esm/classes/queue-getters.js.map +1 -1
  78. package/dist/esm/classes/queue-keys.js +1 -1
  79. package/dist/esm/classes/queue-keys.js.map +1 -1
  80. package/dist/esm/classes/queue.d.ts +54 -0
  81. package/dist/esm/classes/queue.js +74 -0
  82. package/dist/esm/classes/queue.js.map +1 -1
  83. package/dist/esm/classes/repeat.js +9 -10
  84. package/dist/esm/classes/repeat.js.map +1 -1
  85. package/dist/esm/classes/sandbox.js +57 -47
  86. package/dist/esm/classes/sandbox.js.map +1 -1
  87. package/dist/esm/classes/scripts.d.ts +3 -7
  88. package/dist/esm/classes/scripts.js +47 -41
  89. package/dist/esm/classes/scripts.js.map +1 -1
  90. package/dist/esm/classes/worker.d.ts +3 -0
  91. package/dist/esm/classes/worker.js +23 -4
  92. package/dist/esm/classes/worker.js.map +1 -1
  93. package/dist/esm/commands/addDelayedJob-6.lua +7 -7
  94. package/dist/esm/commands/addJobScheduler-2.lua +75 -0
  95. package/dist/esm/commands/addParentJob-4.lua +7 -7
  96. package/dist/esm/commands/addPrioritizedJob-8.lua +7 -7
  97. package/dist/esm/commands/addStandardJob-8.lua +7 -7
  98. package/dist/esm/commands/{cleanJobsInSet-2.lua → cleanJobsInSet-3.lua} +6 -5
  99. package/dist/esm/commands/drain-5.lua +41 -0
  100. package/dist/esm/commands/includes/cleanSet.lua +50 -29
  101. package/dist/esm/commands/includes/deduplicateJob.lua +25 -0
  102. package/dist/esm/commands/includes/removeZSetJobs.lua +13 -1
  103. package/dist/esm/commands/moveStalledJobsToWait-9.lua +2 -4
  104. package/dist/esm/commands/removeJob-2.lua +17 -9
  105. package/dist/esm/commands/removeJobScheduler-3.lua +43 -0
  106. package/dist/esm/enums/error-code.d.ts +2 -1
  107. package/dist/esm/enums/error-code.js +1 -0
  108. package/dist/esm/enums/error-code.js.map +1 -1
  109. package/dist/esm/interfaces/job-json.d.ts +1 -0
  110. package/dist/esm/scripts/addDelayedJob-6.js +18 -16
  111. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  112. package/dist/esm/scripts/addJobScheduler-2.d.ts +5 -0
  113. package/dist/esm/scripts/addJobScheduler-2.js +220 -0
  114. package/dist/esm/scripts/addJobScheduler-2.js.map +1 -0
  115. package/dist/esm/scripts/addParentJob-4.js +18 -16
  116. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  117. package/dist/esm/scripts/addPrioritizedJob-8.js +18 -16
  118. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
  119. package/dist/esm/scripts/addStandardJob-8.js +18 -16
  120. package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
  121. package/dist/esm/scripts/{cleanJobsInSet-2.js → cleanJobsInSet-3.js} +57 -35
  122. package/dist/esm/scripts/{cleanJobsInSet-2.js.map → cleanJobsInSet-3.js.map} +1 -1
  123. package/dist/esm/scripts/{drain-4.js → drain-5.js} +28 -7
  124. package/dist/esm/scripts/drain-5.js.map +1 -0
  125. package/dist/esm/scripts/index.d.ts +4 -2
  126. package/dist/esm/scripts/index.js +4 -2
  127. package/dist/esm/scripts/index.js.map +1 -1
  128. package/dist/esm/scripts/moveStalledJobsToWait-9.js +2 -3
  129. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  130. package/dist/esm/scripts/obliterate-2.js +11 -1
  131. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  132. package/dist/esm/scripts/removeJob-2.js +16 -9
  133. package/dist/esm/scripts/removeJob-2.js.map +1 -1
  134. package/dist/esm/scripts/removeJobScheduler-3.d.ts +5 -0
  135. package/dist/esm/scripts/removeJobScheduler-3.js +46 -0
  136. package/dist/esm/scripts/removeJobScheduler-3.js.map +1 -0
  137. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  138. package/dist/esm/types/job-options.d.ts +5 -0
  139. package/dist/esm/utils.d.ts +7 -0
  140. package/dist/esm/utils.js +23 -0
  141. package/dist/esm/utils.js.map +1 -1
  142. package/package.json +1 -1
  143. package/dist/cjs/commands/drain-4.lua +0 -26
  144. package/dist/cjs/commands/includes/debounceJob.lua +0 -23
  145. package/dist/cjs/scripts/drain-4.js.map +0 -1
  146. package/dist/esm/commands/drain-4.lua +0 -26
  147. package/dist/esm/commands/includes/debounceJob.lua +0 -23
  148. package/dist/esm/scripts/drain-4.js.map +0 -1
  149. /package/dist/esm/scripts/{cleanJobsInSet-2.d.ts → cleanJobsInSet-3.d.ts} +0 -0
  150. /package/dist/esm/scripts/{drain-4.d.ts → drain-5.d.ts} +0 -0
@@ -24,7 +24,7 @@ local rcall = redis.call
24
24
  --- @include "includes/removeJobKeys"
25
25
  --- @include "includes/removeParentDependencyKey"
26
26
 
27
- local function removeJob( prefix, jobId, parentKey, removeChildren)
27
+ local function removeJob(prefix, jobId, parentKey, removeChildren)
28
28
  local jobKey = prefix .. jobId;
29
29
 
30
30
  removeParentDependencyKey(jobKey, false, parentKey, nil)
@@ -33,14 +33,14 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
33
33
  -- Check if this job has children
34
34
  -- If so, we are going to try to remove the children recursively in deep first way because
35
35
  -- if some job is locked we must exit with and error.
36
- --local countProcessed = rcall("HLEN", jobKey .. ":processed")
36
+ -- local countProcessed = rcall("HLEN", jobKey .. ":processed")
37
37
  local processed = rcall("HGETALL", jobKey .. ":processed")
38
38
 
39
39
  if (#processed > 0) then
40
40
  for i = 1, #processed, 2 do
41
41
  local childJobId = getJobIdFromKey(processed[i])
42
42
  local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)
43
- removeJob( childJobPrefix, childJobId, jobKey, removeChildren )
43
+ removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
44
44
  end
45
45
  end
46
46
 
@@ -50,7 +50,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
50
50
  -- We need to get the jobId for this job.
51
51
  local childJobId = getJobIdFromKey(childJobKey)
52
52
  local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
53
- removeJob( childJobPrefix, childJobId, jobKey, removeChildren )
53
+ removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
54
54
  end
55
55
  end
56
56
 
@@ -60,7 +60,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
60
60
  for i = 1, #failed, 2 do
61
61
  local childJobId = getJobIdFromKey(failed[i])
62
62
  local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)
63
- removeJob( childJobPrefix, childJobId, jobKey, removeChildren )
63
+ removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
64
64
  end
65
65
  end
66
66
  end
@@ -70,15 +70,23 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
70
70
  removeDebounceKey(prefix, jobKey)
71
71
  if removeJobKeys(jobKey) > 0 then
72
72
  local maxEvents = getOrSetMaxEvents(KEYS[2])
73
- rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
74
- "jobId", jobId, "prev", prev)
73
+ rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev",
74
+ prev)
75
75
  end
76
76
  end
77
77
 
78
78
  local prefix = KEYS[1]
79
+ local jobId = ARGV[1]
80
+ local shouldRemoveChildren = ARGV[2]
81
+ local jobKey = prefix .. jobId
79
82
 
80
- if not isLocked(prefix, ARGV[1], ARGV[2]) then
81
- removeJob(prefix, ARGV[1], nil, ARGV[2])
83
+ -- Check if the job belongs to a job scheduler and it is in delayed state.
84
+ if rcall("ZSCORE", prefix .. "delayed", jobId) and rcall("HGET", jobKey, "rjk") then
85
+ return -8 -- Return error code as the job is part of a job scheduler and is in delayed state.
86
+ end
87
+
88
+ if not isLocked(prefix, jobId, shouldRemoveChildren) then
89
+ removeJob(prefix, jobId, nil, shouldRemoveChildren)
82
90
  return 1
83
91
  end
84
92
  return 0
@@ -0,0 +1,43 @@
1
+
2
+ --[[
3
+ Removes a repeatable job
4
+ Input:
5
+ KEYS[1] job schedulers key
6
+ KEYS[2] delayed jobs key
7
+ KEYS[3] events key
8
+
9
+ ARGV[1] job scheduler id
10
+ ARGV[2] prefix key
11
+
12
+ Output:
13
+ 0 - OK
14
+ 1 - Missing repeat job
15
+
16
+ Events:
17
+ 'removed'
18
+ ]]
19
+ local rcall = redis.call
20
+
21
+ -- Includes
22
+ --- @include "includes/removeJobKeys"
23
+
24
+ local jobSchedulerId = ARGV[1]
25
+ local prefix = ARGV[2]
26
+
27
+ local millis = rcall("ZSCORE", KEYS[1], jobSchedulerId)
28
+
29
+ if millis then
30
+ -- Delete next programmed job.
31
+ local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. millis
32
+ if(rcall("ZREM", KEYS[2], delayedJobId) == 1) then
33
+ removeJobKeys(prefix .. delayedJobId)
34
+ rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", delayedJobId, "prev", "delayed")
35
+ end
36
+ end
37
+
38
+ if(rcall("ZREM", KEYS[1], jobSchedulerId) == 1) then
39
+ rcall("DEL", KEYS[1] .. ":" .. jobSchedulerId)
40
+ return 0
41
+ end
42
+
43
+ return 1
@@ -10,5 +10,6 @@ var ErrorCode;
10
10
  ErrorCode[ErrorCode["ParentJobNotExist"] = -5] = "ParentJobNotExist";
11
11
  ErrorCode[ErrorCode["JobLockMismatch"] = -6] = "JobLockMismatch";
12
12
  ErrorCode[ErrorCode["ParentJobCannotBeReplaced"] = -7] = "ParentJobCannotBeReplaced";
13
+ ErrorCode[ErrorCode["JobBelongsToJobScheduler"] = -8] = "JobBelongsToJobScheduler";
13
14
  })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
14
15
  //# sourceMappingURL=error-code.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-code.js","sourceRoot":"","sources":["../../../src/enums/error-code.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,wDAAgB,CAAA;IAChB,gEAAoB,CAAA;IACpB,4DAAkB,CAAA;IAClB,8EAA2B,CAAA;IAC3B,oEAAsB,CAAA;IACtB,gEAAoB,CAAA;IACpB,oFAA8B,CAAA;AAChC,CAAC,EARW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAQpB"}
1
+ {"version":3,"file":"error-code.js","sourceRoot":"","sources":["../../../src/enums/error-code.ts"],"names":[],"mappings":";;;AAAA,IAAY,SASX;AATD,WAAY,SAAS;IACnB,wDAAgB,CAAA;IAChB,gEAAoB,CAAA;IACpB,4DAAkB,CAAA;IAClB,8EAA2B,CAAA;IAC3B,oEAAsB,CAAA;IACtB,gEAAoB,CAAA;IACpB,oFAA8B,CAAA;IAC9B,kFAA6B,CAAA;AAC/B,CAAC,EATW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QASpB"}
@@ -25,7 +25,7 @@ const content = `--[[
25
25
  [7] parent dependencies key.
26
26
  [8] parent? {id, queueKey}
27
27
  [9] repeat job key
28
- [10] debounce key
28
+ [10] deduplication key
29
29
  ARGV[2] Json stringified job data
30
30
  ARGV[3] msgpacked options
31
31
  Output:
@@ -45,7 +45,7 @@ local data = ARGV[2]
45
45
  local parentKey = args[5]
46
46
  local parent = args[8]
47
47
  local repeatJobKey = args[9]
48
- local debounceKey = args[10]
48
+ local deduplicationKey = args[10]
49
49
  local parentData
50
50
  -- Includes
51
51
  --[[
@@ -75,20 +75,22 @@ end
75
75
  --[[
76
76
  Function to debounce a job.
77
77
  ]]
78
- local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
79
- local debounceId = debounceOpts and debounceOpts['id']
80
- if debounceId then
81
- local ttl = debounceOpts['ttl']
82
- local debounceKeyExists
78
+ local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
79
+ local deduplicationId = deduplicationOpts and deduplicationOpts['id']
80
+ if deduplicationId then
81
+ local ttl = deduplicationOpts['ttl']
82
+ local deduplicationKeyExists
83
83
  if ttl then
84
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
84
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
85
85
  else
86
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
86
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
87
87
  end
88
- if debounceKeyExists then
89
- local currentDebounceJobId = rcall('GET', debounceKey)
88
+ if deduplicationKeyExists then
89
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
90
90
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
91
- "debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
91
+ "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
92
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
93
+ "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
92
94
  return currentDebounceJobId
93
95
  end
94
96
  end
@@ -341,10 +343,10 @@ else
341
343
  maxEvents, timestamp)
342
344
  end
343
345
  end
344
- local debouncedJobId = debounceJob(args[1], opts['de'],
345
- jobId, debounceKey, eventsKey, maxEvents)
346
- if debouncedJobId then
347
- return debouncedJobId
346
+ local deduplicationJobId = deduplicateJob(args[1], opts['de'],
347
+ jobId, deduplicationKey, eventsKey, maxEvents)
348
+ if deduplicationJobId then
349
+ return deduplicationJobId
348
350
  end
349
351
  -- Store the job.
350
352
  local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
@@ -1 +1 @@
1
- {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyWf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Wf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addJobScheduler = void 0;
4
+ const content = `--[[
5
+ Adds a job scheduler, i.e. a job factory that creates jobs based on a given schedule (repeat options).
6
+ Input:
7
+ KEYS[1] 'repeat' key
8
+ KEYS[2] 'delayed' key
9
+ ARGV[1] next milliseconds
10
+ ARGV[2] msgpacked options
11
+ [1] name
12
+ [2] tz?
13
+ [3] patten?
14
+ [4] endDate?
15
+ [5] every?
16
+ ARGV[3] jobs scheduler id
17
+ ARGV[4] prefix key
18
+ Output:
19
+ repeatableKey - OK
20
+ ]]
21
+ local rcall = redis.call
22
+ local repeatKey = KEYS[1]
23
+ local delayedKey = KEYS[2]
24
+ local nextMillis = ARGV[1]
25
+ local jobSchedulerId = ARGV[3]
26
+ local prefixKey = ARGV[4]
27
+ -- Includes
28
+ --[[
29
+ Function to remove job.
30
+ ]]
31
+ -- Includes
32
+ --[[
33
+ Function to remove debounce key.
34
+ ]]
35
+ local function removeDebounceKey(prefixKey, jobKey)
36
+ local debounceId = rcall("HGET", jobKey, "deid")
37
+ if debounceId then
38
+ local debounceKey = prefixKey .. "de:" .. debounceId
39
+ rcall("DEL", debounceKey)
40
+ end
41
+ end
42
+ --[[
43
+ Function to remove job keys.
44
+ ]]
45
+ local function removeJobKeys(jobKey)
46
+ return rcall("DEL", jobKey, jobKey .. ':logs',
47
+ jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
48
+ end
49
+ --[[
50
+ Check if this job has a parent. If so we will just remove it from
51
+ the parent child list, but if it is the last child we should move the parent to "wait/paused"
52
+ which requires code from "moveToFinished"
53
+ ]]
54
+ -- Includes
55
+ --[[
56
+ Function to add job in target list and add marker if needed.
57
+ ]]
58
+ -- Includes
59
+ --[[
60
+ Add marker if needed when a job is available.
61
+ ]]
62
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
63
+ if not isPausedOrMaxed then
64
+ rcall("ZADD", markerKey, 0, "0")
65
+ end
66
+ end
67
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
68
+ rcall(pushCmd, targetKey, jobId)
69
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
70
+ end
71
+ --[[
72
+ Functions to destructure job key.
73
+ Just a bit of warning, these functions may be a bit slow and affect performance significantly.
74
+ ]]
75
+ local getJobIdFromKey = function (jobKey)
76
+ return string.match(jobKey, ".*:(.*)")
77
+ end
78
+ local getJobKeyPrefix = function (jobKey, jobId)
79
+ return string.sub(jobKey, 0, #jobKey - #jobId)
80
+ end
81
+ --[[
82
+ Function to check for the meta.paused key to decide if we are paused or not
83
+ (since an empty list and !EXISTS are not really the same).
84
+ ]]
85
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
86
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
87
+ if queueAttributes[1] then
88
+ return pausedKey, true
89
+ else
90
+ if queueAttributes[2] then
91
+ local activeCount = rcall("LLEN", activeKey)
92
+ if activeCount >= tonumber(queueAttributes[2]) then
93
+ return waitKey, true
94
+ else
95
+ return waitKey, false
96
+ end
97
+ end
98
+ end
99
+ return waitKey, false
100
+ end
101
+ local function moveParentToWait(parentPrefix, parentId, emitEvent)
102
+ local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
103
+ parentPrefix .. "wait", parentPrefix .. "paused")
104
+ addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
105
+ if emitEvent then
106
+ local parentEventStream = parentPrefix .. "events"
107
+ rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
108
+ end
109
+ end
110
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
111
+ if parentKey then
112
+ local parentDependenciesKey = parentKey .. ":dependencies"
113
+ local result = rcall("SREM", parentDependenciesKey, jobKey)
114
+ if result > 0 then
115
+ local pendingDependencies = rcall("SCARD", parentDependenciesKey)
116
+ if pendingDependencies == 0 then
117
+ local parentId = getJobIdFromKey(parentKey)
118
+ local parentPrefix = getJobKeyPrefix(parentKey, parentId)
119
+ local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
120
+ if numRemovedElements == 1 then
121
+ if hard then -- remove parent in same queue
122
+ if parentPrefix == baseKey then
123
+ removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
124
+ removeJobKeys(parentKey)
125
+ if debounceId then
126
+ rcall("DEL", parentPrefix .. "de:" .. debounceId)
127
+ end
128
+ else
129
+ moveParentToWait(parentPrefix, parentId)
130
+ end
131
+ else
132
+ moveParentToWait(parentPrefix, parentId, true)
133
+ end
134
+ end
135
+ end
136
+ return true
137
+ end
138
+ else
139
+ local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
140
+ local missedParentKey = parentAttributes[1]
141
+ if( (type(missedParentKey) == "string") and missedParentKey ~= ""
142
+ and (rcall("EXISTS", missedParentKey) == 1)) then
143
+ local parentDependenciesKey = missedParentKey .. ":dependencies"
144
+ local result = rcall("SREM", parentDependenciesKey, jobKey)
145
+ if result > 0 then
146
+ local pendingDependencies = rcall("SCARD", parentDependenciesKey)
147
+ if pendingDependencies == 0 then
148
+ local parentId = getJobIdFromKey(missedParentKey)
149
+ local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
150
+ local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
151
+ if numRemovedElements == 1 then
152
+ if hard then
153
+ if parentPrefix == baseKey then
154
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
155
+ removeJobKeys(missedParentKey)
156
+ if parentAttributes[2] then
157
+ rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
158
+ end
159
+ else
160
+ moveParentToWait(parentPrefix, parentId)
161
+ end
162
+ else
163
+ moveParentToWait(parentPrefix, parentId, true)
164
+ end
165
+ end
166
+ end
167
+ return true
168
+ end
169
+ end
170
+ end
171
+ return false
172
+ end
173
+ local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
174
+ local jobKey = baseKey .. jobId
175
+ removeParentDependencyKey(jobKey, hard, nil, baseKey)
176
+ if shouldRemoveDebounceKey then
177
+ removeDebounceKey(baseKey, jobKey)
178
+ end
179
+ removeJobKeys(jobKey)
180
+ end
181
+ local function storeRepeatableJob(repeatKey, nextMillis, rawOpts)
182
+ rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
183
+ local opts = cmsgpack.unpack(rawOpts)
184
+ local optionalValues = {}
185
+ if opts['tz'] then
186
+ table.insert(optionalValues, "tz")
187
+ table.insert(optionalValues, opts['tz'])
188
+ end
189
+ if opts['pattern'] then
190
+ table.insert(optionalValues, "pattern")
191
+ table.insert(optionalValues, opts['pattern'])
192
+ end
193
+ if opts['endDate'] then
194
+ table.insert(optionalValues, "endDate")
195
+ table.insert(optionalValues, opts['endDate'])
196
+ end
197
+ if opts['every'] then
198
+ table.insert(optionalValues, "every")
199
+ table.insert(optionalValues, opts['every'])
200
+ end
201
+ rcall("HMSET", repeatKey .. ":" .. jobSchedulerId, "name", opts['name'],
202
+ unpack(optionalValues))
203
+ end
204
+ -- If we are overriding a repeatable job we must delete the delayed job for
205
+ -- the next iteration.
206
+ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
207
+ if prevMillis ~= false then
208
+ local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
209
+ local nextDelayedJobId = repeatKey .. ":" .. jobSchedulerId .. ":" .. nextMillis
210
+ if rcall("ZSCORE", delayedKey, delayedJobId) ~= false
211
+ and rcall("EXISTS", nextDelayedJobId) ~= 1 then
212
+ removeJob(delayedJobId, true, prefixKey, true --[[remove debounce key]])
213
+ rcall("ZREM", delayedKey, delayedJobId)
214
+ end
215
+ end
216
+ return storeRepeatableJob(repeatKey, nextMillis, ARGV[2])
217
+ `;
218
+ exports.addJobScheduler = {
219
+ name: 'addJobScheduler',
220
+ content,
221
+ keys: 2,
222
+ };
223
+ //# sourceMappingURL=addJobScheduler-2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addJobScheduler-2.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqNf,CAAC;AACW,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -21,7 +21,7 @@ const content = `--[[
21
21
  [7] parent dependencies key.
22
22
  [8] parent? {id, queueKey}
23
23
  [9] repeat job key
24
- [10] debounce key
24
+ [10] deduplication key
25
25
  ARGV[2] Json stringified job data
26
26
  ARGV[3] msgpacked options
27
27
  Output:
@@ -41,26 +41,28 @@ local opts = cmsgpack.unpack(ARGV[3])
41
41
  local parentKey = args[5]
42
42
  local parent = args[8]
43
43
  local repeatJobKey = args[9]
44
- local debounceKey = args[10]
44
+ local deduplicationKey = args[10]
45
45
  local parentData
46
46
  -- Includes
47
47
  --[[
48
48
  Function to debounce a job.
49
49
  ]]
50
- local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
51
- local debounceId = debounceOpts and debounceOpts['id']
52
- if debounceId then
53
- local ttl = debounceOpts['ttl']
54
- local debounceKeyExists
50
+ local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
51
+ local deduplicationId = deduplicationOpts and deduplicationOpts['id']
52
+ if deduplicationId then
53
+ local ttl = deduplicationOpts['ttl']
54
+ local deduplicationKeyExists
55
55
  if ttl then
56
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
56
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
57
57
  else
58
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
58
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
59
59
  end
60
- if debounceKeyExists then
61
- local currentDebounceJobId = rcall('GET', debounceKey)
60
+ if deduplicationKeyExists then
61
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
62
62
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
63
- "debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
63
+ "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
64
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
65
+ "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
64
66
  return currentDebounceJobId
65
67
  end
66
68
  end
@@ -312,10 +314,10 @@ else
312
314
  maxEvents, timestamp)
313
315
  end
314
316
  end
315
- local debouncedJobId = debounceJob(args[1], opts['de'],
316
- jobId, debounceKey, eventsKey, maxEvents)
317
- if debouncedJobId then
318
- return debouncedJobId
317
+ local deduplicationJobId = deduplicateJob(args[1], opts['de'],
318
+ jobId, deduplicationKey, eventsKey, maxEvents)
319
+ if deduplicationJobId then
320
+ return deduplicationJobId
319
321
  end
320
322
  -- Store the job.
321
323
  storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
@@ -1 +1 @@
1
- {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwUf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Uf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -25,7 +25,7 @@ const content = `--[[
25
25
  [7] parent dependencies key.
26
26
  [8] parent? {id, queueKey}
27
27
  [9] repeat job key
28
- [10] debounce key
28
+ [10] deduplication key
29
29
  ARGV[2] Json stringified job data
30
30
  ARGV[3] msgpacked options
31
31
  Output:
@@ -48,7 +48,7 @@ local opts = cmsgpack.unpack(ARGV[3])
48
48
  local parentKey = args[5]
49
49
  local parent = args[8]
50
50
  local repeatJobKey = args[9]
51
- local debounceKey = args[10]
51
+ local deduplicationKey = args[10]
52
52
  local parentData
53
53
  -- Includes
54
54
  --[[
@@ -73,20 +73,22 @@ end
73
73
  --[[
74
74
  Function to debounce a job.
75
75
  ]]
76
- local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
77
- local debounceId = debounceOpts and debounceOpts['id']
78
- if debounceId then
79
- local ttl = debounceOpts['ttl']
80
- local debounceKeyExists
76
+ local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
77
+ local deduplicationId = deduplicationOpts and deduplicationOpts['id']
78
+ if deduplicationId then
79
+ local ttl = deduplicationOpts['ttl']
80
+ local deduplicationKeyExists
81
81
  if ttl then
82
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
82
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
83
83
  else
84
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
84
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
85
85
  end
86
- if debounceKeyExists then
87
- local currentDebounceJobId = rcall('GET', debounceKey)
86
+ if deduplicationKeyExists then
87
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
88
88
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
89
- "debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
89
+ "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
90
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
91
+ "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
90
92
  return currentDebounceJobId
91
93
  end
92
94
  end
@@ -319,10 +321,10 @@ else
319
321
  maxEvents, timestamp)
320
322
  end
321
323
  end
322
- local debouncedJobId = debounceJob(args[1], opts['de'],
323
- jobId, debounceKey, eventsKey, maxEvents)
324
- if debouncedJobId then
325
- return debouncedJobId
324
+ local deduplicationJobId = deduplicateJob(args[1], opts['de'],
325
+ jobId, deduplicationKey, eventsKey, maxEvents)
326
+ if deduplicationJobId then
327
+ return deduplicationJobId
326
328
  end
327
329
  -- Store the job.
328
330
  local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
@@ -1 +1 @@
1
- {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkVf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -34,7 +34,7 @@ const content = `--[[
34
34
  [7] parent dependencies key.
35
35
  [8] parent? {id, queueKey}
36
36
  [9] repeat job key
37
- [10] debounce key
37
+ [10] deduplication key
38
38
  ARGV[2] Json stringified job data
39
39
  ARGV[3] msgpacked options
40
40
  Output:
@@ -51,7 +51,7 @@ local opts = cmsgpack.unpack(ARGV[3])
51
51
  local parentKey = args[5]
52
52
  local parent = args[8]
53
53
  local repeatJobKey = args[9]
54
- local debounceKey = args[10]
54
+ local deduplicationKey = args[10]
55
55
  local parentData
56
56
  -- Includes
57
57
  --[[
@@ -73,20 +73,22 @@ end
73
73
  --[[
74
74
  Function to debounce a job.
75
75
  ]]
76
- local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
77
- local debounceId = debounceOpts and debounceOpts['id']
78
- if debounceId then
79
- local ttl = debounceOpts['ttl']
80
- local debounceKeyExists
76
+ local function deduplicateJob(prefixKey, deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
77
+ local deduplicationId = deduplicationOpts and deduplicationOpts['id']
78
+ if deduplicationId then
79
+ local ttl = deduplicationOpts['ttl']
80
+ local deduplicationKeyExists
81
81
  if ttl then
82
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
82
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
83
83
  else
84
- debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
84
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
85
85
  end
86
- if debounceKeyExists then
87
- local currentDebounceJobId = rcall('GET', debounceKey)
86
+ if deduplicationKeyExists then
87
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
88
88
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
89
- "debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
89
+ "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
90
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
91
+ "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
90
92
  return currentDebounceJobId
91
93
  end
92
94
  end
@@ -323,10 +325,10 @@ else
323
325
  maxEvents, timestamp)
324
326
  end
325
327
  end
326
- local debouncedJobId = debounceJob(args[1], opts['de'],
327
- jobId, debounceKey, eventsKey, maxEvents)
328
- if debouncedJobId then
329
- return debouncedJobId
328
+ local deduplicationJobId = deduplicateJob(args[1], opts['de'],
329
+ jobId, deduplicationKey, eventsKey, maxEvents)
330
+ if deduplicationJobId then
331
+ return deduplicationJobId
330
332
  end
331
333
  -- Store the job.
332
334
  storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
@@ -1 +1 @@
1
- {"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsVf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwVf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}