bullmq 5.58.9 → 5.59.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.
- package/dist/cjs/classes/child-pool.js +8 -1
- package/dist/cjs/classes/child-pool.js.map +1 -1
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.js +42 -30
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/includes/deduplicateJob.lua +53 -20
- package/dist/cjs/commands/moveJobFromActiveToWait-9.lua +1 -1
- package/dist/cjs/commands/moveToDelayed-8.lua +2 -1
- package/dist/cjs/scripts/addDelayedJob-6.js +47 -18
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-5.js +47 -18
- package/dist/cjs/scripts/addParentJob-5.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-9.js +47 -18
- package/dist/cjs/scripts/addPrioritizedJob-9.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-9.js +47 -18
- package/dist/cjs/scripts/addStandardJob-9.js.map +1 -1
- package/dist/cjs/scripts/moveJobFromActiveToWait-9.js +1 -1
- package/dist/cjs/scripts/moveToDelayed-8.js +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/child-pool.js +8 -1
- package/dist/esm/classes/child-pool.js.map +1 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.d.ts +1 -0
- package/dist/esm/classes/worker.js +42 -30
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/includes/deduplicateJob.lua +53 -20
- package/dist/esm/commands/moveJobFromActiveToWait-9.lua +1 -1
- package/dist/esm/commands/moveToDelayed-8.lua +2 -1
- package/dist/esm/interfaces/base-job-options.d.ts +1 -1
- package/dist/esm/interfaces/worker-options.d.ts +8 -0
- package/dist/esm/scripts/addDelayedJob-6.js +47 -18
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-5.js +47 -18
- package/dist/esm/scripts/addParentJob-5.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-9.js +47 -18
- package/dist/esm/scripts/addPrioritizedJob-9.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-9.js +47 -18
- package/dist/esm/scripts/addStandardJob-9.js.map +1 -1
- package/dist/esm/scripts/moveJobFromActiveToWait-9.js +1 -1
- package/dist/esm/scripts/moveToDelayed-8.js +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 +1 -1
|
@@ -36,6 +36,14 @@ export interface WorkerOptions extends QueueBaseOptions, SandboxedOptions {
|
|
|
36
36
|
* @see {@link https://docs.bullmq.io/guide/metrics}
|
|
37
37
|
*/
|
|
38
38
|
metrics?: MetricsOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Defines the maximum number of times a job is allowed to start processing,
|
|
41
|
+
* regardless of whether it completes or fails. Each time a worker picks up the job
|
|
42
|
+
* and begins processing it, the attemptsStarted counter is incremented.
|
|
43
|
+
* If this counter reaches maxStartedAttempts, the job will be moved to the failed state with an UnrecoverableError.
|
|
44
|
+
* @defaultValue undefined
|
|
45
|
+
*/
|
|
46
|
+
maxStartedAttempts?: number;
|
|
39
47
|
/**
|
|
40
48
|
* Amount of times a job can be recovered from a stalled state
|
|
41
49
|
* to the `wait` state. If this is exceeded, the job is moved
|
|
@@ -120,37 +120,65 @@ local function removeJobKeys(jobKey)
|
|
|
120
120
|
return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
|
|
121
121
|
jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
|
|
122
122
|
end
|
|
123
|
+
local function removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents, currentDeduplicatedJobId,
|
|
124
|
+
jobId, deduplicationId, prefix)
|
|
125
|
+
if rcall("ZREM", delayedKey, currentDeduplicatedJobId) > 0 then
|
|
126
|
+
removeJobKeys(prefix .. currentDeduplicatedJobId)
|
|
127
|
+
rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDeduplicatedJobId,
|
|
128
|
+
"prev", "delayed")
|
|
129
|
+
-- TODO remove debounced event in next breaking change
|
|
130
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
131
|
+
jobId, "debounceId", deduplicationId)
|
|
132
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
133
|
+
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDeduplicatedJobId)
|
|
134
|
+
return true
|
|
135
|
+
end
|
|
136
|
+
return false
|
|
137
|
+
end
|
|
123
138
|
local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
124
139
|
prefix)
|
|
125
140
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
|
126
141
|
if deduplicationId then
|
|
127
142
|
local ttl = deduplicationOpts['ttl']
|
|
128
|
-
if deduplicationOpts['replace']
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
143
|
+
if deduplicationOpts['replace'] then
|
|
144
|
+
if ttl and ttl > 0 then
|
|
145
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
146
|
+
if currentDebounceJobId then
|
|
147
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
148
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
149
|
+
if isRemoved then
|
|
150
|
+
if deduplicationOpts['extend'] then
|
|
151
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
152
|
+
else
|
|
153
|
+
rcall('SET', deduplicationKey, jobId, 'KEEPTTL')
|
|
154
|
+
end
|
|
155
|
+
return
|
|
137
156
|
else
|
|
138
|
-
|
|
157
|
+
return currentDebounceJobId
|
|
139
158
|
end
|
|
140
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
141
|
-
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)
|
|
142
|
-
return
|
|
143
159
|
else
|
|
144
|
-
|
|
160
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
161
|
+
return
|
|
145
162
|
end
|
|
146
163
|
else
|
|
147
|
-
rcall('
|
|
148
|
-
|
|
164
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
165
|
+
if currentDebounceJobId then
|
|
166
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
167
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
168
|
+
if isRemoved then
|
|
169
|
+
rcall('SET', deduplicationKey, jobId)
|
|
170
|
+
return
|
|
171
|
+
else
|
|
172
|
+
return currentDebounceJobId
|
|
173
|
+
end
|
|
174
|
+
else
|
|
175
|
+
rcall('SET', deduplicationKey, jobId)
|
|
176
|
+
return
|
|
177
|
+
end
|
|
149
178
|
end
|
|
150
179
|
else
|
|
151
|
-
local ttl = deduplicationOpts['ttl']
|
|
152
180
|
local deduplicationKeyExists
|
|
153
|
-
if ttl then
|
|
181
|
+
if ttl and ttl > 0 then
|
|
154
182
|
if deduplicationOpts['extend'] then
|
|
155
183
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
156
184
|
if currentDebounceJobId then
|
|
@@ -172,6 +200,7 @@ local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicatio
|
|
|
172
200
|
end
|
|
173
201
|
if deduplicationKeyExists then
|
|
174
202
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
203
|
+
-- TODO remove debounced event in next breaking change
|
|
175
204
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
176
205
|
currentDebounceJobId, "debounceId", deduplicationId)
|
|
177
206
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAudf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -53,37 +53,65 @@ local function removeJobKeys(jobKey)
|
|
|
53
53
|
return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
|
|
54
54
|
jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
|
|
55
55
|
end
|
|
56
|
+
local function removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents, currentDeduplicatedJobId,
|
|
57
|
+
jobId, deduplicationId, prefix)
|
|
58
|
+
if rcall("ZREM", delayedKey, currentDeduplicatedJobId) > 0 then
|
|
59
|
+
removeJobKeys(prefix .. currentDeduplicatedJobId)
|
|
60
|
+
rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDeduplicatedJobId,
|
|
61
|
+
"prev", "delayed")
|
|
62
|
+
-- TODO remove debounced event in next breaking change
|
|
63
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
64
|
+
jobId, "debounceId", deduplicationId)
|
|
65
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
66
|
+
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDeduplicatedJobId)
|
|
67
|
+
return true
|
|
68
|
+
end
|
|
69
|
+
return false
|
|
70
|
+
end
|
|
56
71
|
local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
57
72
|
prefix)
|
|
58
73
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
|
59
74
|
if deduplicationId then
|
|
60
75
|
local ttl = deduplicationOpts['ttl']
|
|
61
|
-
if deduplicationOpts['replace']
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
if deduplicationOpts['replace'] then
|
|
77
|
+
if ttl and ttl > 0 then
|
|
78
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
79
|
+
if currentDebounceJobId then
|
|
80
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
81
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
82
|
+
if isRemoved then
|
|
83
|
+
if deduplicationOpts['extend'] then
|
|
84
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
85
|
+
else
|
|
86
|
+
rcall('SET', deduplicationKey, jobId, 'KEEPTTL')
|
|
87
|
+
end
|
|
88
|
+
return
|
|
70
89
|
else
|
|
71
|
-
|
|
90
|
+
return currentDebounceJobId
|
|
72
91
|
end
|
|
73
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
74
|
-
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)
|
|
75
|
-
return
|
|
76
92
|
else
|
|
77
|
-
|
|
93
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
94
|
+
return
|
|
78
95
|
end
|
|
79
96
|
else
|
|
80
|
-
rcall('
|
|
81
|
-
|
|
97
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
98
|
+
if currentDebounceJobId then
|
|
99
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
100
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
101
|
+
if isRemoved then
|
|
102
|
+
rcall('SET', deduplicationKey, jobId)
|
|
103
|
+
return
|
|
104
|
+
else
|
|
105
|
+
return currentDebounceJobId
|
|
106
|
+
end
|
|
107
|
+
else
|
|
108
|
+
rcall('SET', deduplicationKey, jobId)
|
|
109
|
+
return
|
|
110
|
+
end
|
|
82
111
|
end
|
|
83
112
|
else
|
|
84
|
-
local ttl = deduplicationOpts['ttl']
|
|
85
113
|
local deduplicationKeyExists
|
|
86
|
-
if ttl then
|
|
114
|
+
if ttl and ttl > 0 then
|
|
87
115
|
if deduplicationOpts['extend'] then
|
|
88
116
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
89
117
|
if currentDebounceJobId then
|
|
@@ -105,6 +133,7 @@ local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicatio
|
|
|
105
133
|
end
|
|
106
134
|
if deduplicationKeyExists then
|
|
107
135
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
136
|
+
-- TODO remove debounced event in next breaking change
|
|
108
137
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
109
138
|
currentDebounceJobId, "debounceId", deduplicationId)
|
|
110
139
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addParentJob-5.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"addParentJob-5.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+af,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -85,37 +85,65 @@ local function removeJobKeys(jobKey)
|
|
|
85
85
|
return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
|
|
86
86
|
jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
|
|
87
87
|
end
|
|
88
|
+
local function removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents, currentDeduplicatedJobId,
|
|
89
|
+
jobId, deduplicationId, prefix)
|
|
90
|
+
if rcall("ZREM", delayedKey, currentDeduplicatedJobId) > 0 then
|
|
91
|
+
removeJobKeys(prefix .. currentDeduplicatedJobId)
|
|
92
|
+
rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDeduplicatedJobId,
|
|
93
|
+
"prev", "delayed")
|
|
94
|
+
-- TODO remove debounced event in next breaking change
|
|
95
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
96
|
+
jobId, "debounceId", deduplicationId)
|
|
97
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
98
|
+
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDeduplicatedJobId)
|
|
99
|
+
return true
|
|
100
|
+
end
|
|
101
|
+
return false
|
|
102
|
+
end
|
|
88
103
|
local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
89
104
|
prefix)
|
|
90
105
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
|
91
106
|
if deduplicationId then
|
|
92
107
|
local ttl = deduplicationOpts['ttl']
|
|
93
|
-
if deduplicationOpts['replace']
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
if deduplicationOpts['replace'] then
|
|
109
|
+
if ttl and ttl > 0 then
|
|
110
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
111
|
+
if currentDebounceJobId then
|
|
112
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
113
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
114
|
+
if isRemoved then
|
|
115
|
+
if deduplicationOpts['extend'] then
|
|
116
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
117
|
+
else
|
|
118
|
+
rcall('SET', deduplicationKey, jobId, 'KEEPTTL')
|
|
119
|
+
end
|
|
120
|
+
return
|
|
102
121
|
else
|
|
103
|
-
|
|
122
|
+
return currentDebounceJobId
|
|
104
123
|
end
|
|
105
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
106
|
-
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)
|
|
107
|
-
return
|
|
108
124
|
else
|
|
109
|
-
|
|
125
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
126
|
+
return
|
|
110
127
|
end
|
|
111
128
|
else
|
|
112
|
-
rcall('
|
|
113
|
-
|
|
129
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
130
|
+
if currentDebounceJobId then
|
|
131
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
132
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
133
|
+
if isRemoved then
|
|
134
|
+
rcall('SET', deduplicationKey, jobId)
|
|
135
|
+
return
|
|
136
|
+
else
|
|
137
|
+
return currentDebounceJobId
|
|
138
|
+
end
|
|
139
|
+
else
|
|
140
|
+
rcall('SET', deduplicationKey, jobId)
|
|
141
|
+
return
|
|
142
|
+
end
|
|
114
143
|
end
|
|
115
144
|
else
|
|
116
|
-
local ttl = deduplicationOpts['ttl']
|
|
117
145
|
local deduplicationKeyExists
|
|
118
|
-
if ttl then
|
|
146
|
+
if ttl and ttl > 0 then
|
|
119
147
|
if deduplicationOpts['extend'] then
|
|
120
148
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
121
149
|
if currentDebounceJobId then
|
|
@@ -137,6 +165,7 @@ local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicatio
|
|
|
137
165
|
end
|
|
138
166
|
if deduplicationKeyExists then
|
|
139
167
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
168
|
+
-- TODO remove debounced event in next breaking change
|
|
140
169
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
141
170
|
currentDebounceJobId, "debounceId", deduplicationId)
|
|
142
171
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addPrioritizedJob-9.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"addPrioritizedJob-9.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAybf,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -79,37 +79,65 @@ local function removeJobKeys(jobKey)
|
|
|
79
79
|
return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
|
|
80
80
|
jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
|
|
81
81
|
end
|
|
82
|
+
local function removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents, currentDeduplicatedJobId,
|
|
83
|
+
jobId, deduplicationId, prefix)
|
|
84
|
+
if rcall("ZREM", delayedKey, currentDeduplicatedJobId) > 0 then
|
|
85
|
+
removeJobKeys(prefix .. currentDeduplicatedJobId)
|
|
86
|
+
rcall("XADD", eventsKey, "*", "event", "removed", "jobId", currentDeduplicatedJobId,
|
|
87
|
+
"prev", "delayed")
|
|
88
|
+
-- TODO remove debounced event in next breaking change
|
|
89
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
90
|
+
jobId, "debounceId", deduplicationId)
|
|
91
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
92
|
+
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDeduplicatedJobId)
|
|
93
|
+
return true
|
|
94
|
+
end
|
|
95
|
+
return false
|
|
96
|
+
end
|
|
82
97
|
local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
83
98
|
prefix)
|
|
84
99
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
|
85
100
|
if deduplicationId then
|
|
86
101
|
local ttl = deduplicationOpts['ttl']
|
|
87
|
-
if deduplicationOpts['replace']
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
if deduplicationOpts['replace'] then
|
|
103
|
+
if ttl and ttl > 0 then
|
|
104
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
105
|
+
if currentDebounceJobId then
|
|
106
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
107
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
108
|
+
if isRemoved then
|
|
109
|
+
if deduplicationOpts['extend'] then
|
|
110
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
111
|
+
else
|
|
112
|
+
rcall('SET', deduplicationKey, jobId, 'KEEPTTL')
|
|
113
|
+
end
|
|
114
|
+
return
|
|
96
115
|
else
|
|
97
|
-
|
|
116
|
+
return currentDebounceJobId
|
|
98
117
|
end
|
|
99
|
-
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
100
|
-
jobId, "deduplicationId", deduplicationId, "deduplicatedJobId", currentDebounceJobId)
|
|
101
|
-
return
|
|
102
118
|
else
|
|
103
|
-
|
|
119
|
+
rcall('SET', deduplicationKey, jobId, 'PX', ttl)
|
|
120
|
+
return
|
|
104
121
|
end
|
|
105
122
|
else
|
|
106
|
-
rcall('
|
|
107
|
-
|
|
123
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
124
|
+
if currentDebounceJobId then
|
|
125
|
+
local isRemoved = removeDelayedJob(delayedKey, deduplicationKey, eventsKey, maxEvents,
|
|
126
|
+
currentDebounceJobId, jobId, deduplicationId, prefix)
|
|
127
|
+
if isRemoved then
|
|
128
|
+
rcall('SET', deduplicationKey, jobId)
|
|
129
|
+
return
|
|
130
|
+
else
|
|
131
|
+
return currentDebounceJobId
|
|
132
|
+
end
|
|
133
|
+
else
|
|
134
|
+
rcall('SET', deduplicationKey, jobId)
|
|
135
|
+
return
|
|
136
|
+
end
|
|
108
137
|
end
|
|
109
138
|
else
|
|
110
|
-
local ttl = deduplicationOpts['ttl']
|
|
111
139
|
local deduplicationKeyExists
|
|
112
|
-
if ttl then
|
|
140
|
+
if ttl and ttl > 0 then
|
|
113
141
|
if deduplicationOpts['extend'] then
|
|
114
142
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
115
143
|
if currentDebounceJobId then
|
|
@@ -131,6 +159,7 @@ local function deduplicateJob(deduplicationOpts, jobId, delayedKey, deduplicatio
|
|
|
131
159
|
end
|
|
132
160
|
if deduplicationKeyExists then
|
|
133
161
|
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
|
162
|
+
-- TODO remove debounced event in next breaking change
|
|
134
163
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId",
|
|
135
164
|
currentDebounceJobId, "debounceId", deduplicationId)
|
|
136
165
|
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addStandardJob-9.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"addStandardJob-9.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6bf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -126,9 +126,9 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
126
126
|
local delayedKey = KEYS[4]
|
|
127
127
|
local jobId = ARGV[3]
|
|
128
128
|
local delay = tonumber(ARGV[5])
|
|
129
|
-
local score, delayedTimestamp = getDelayedScore(delayedKey, ARGV[2], delay)
|
|
130
129
|
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
|
131
130
|
if numRemovedElements < 1 then return -3 end
|
|
131
|
+
local score, delayedTimestamp = getDelayedScore(delayedKey, ARGV[2], delay)
|
|
132
132
|
if ARGV[6] == "0" then
|
|
133
133
|
rcall("HINCRBY", jobKey, "atm", 1)
|
|
134
134
|
end
|