qdone 2.0.37-alpha → 2.0.39-alpha
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/commonjs/src/dedup.js
CHANGED
|
@@ -209,6 +209,7 @@ exports.dedupShouldEnqueueMulti = dedupShouldEnqueueMulti;
|
|
|
209
209
|
* @returns {Number} 1 if a cache key was deleted, otherwise 0
|
|
210
210
|
*/
|
|
211
211
|
async function dedupSuccessfullyProcessed(message, opt) {
|
|
212
|
+
debug({ dedupSuccessfullyProcessed: { message, opt } });
|
|
212
213
|
const client = (0, cache_js_1.getCacheClient)(opt);
|
|
213
214
|
const dedupId = message?.MessageAttributes?.QdoneDeduplicationId?.StringValue;
|
|
214
215
|
if (dedupId) {
|
package/commonjs/src/enqueue.js
CHANGED
|
@@ -276,9 +276,9 @@ async function sendMessageBatch(qrl, messages, opt) {
|
|
|
276
276
|
if (opt.externalDedup) {
|
|
277
277
|
const promises = params.Entries.map(async (m) => ({ m, shouldEnqueue: await (0, dedup_js_1.dedupShouldEnqueue)(m, opt) }));
|
|
278
278
|
const results = await Promise.all(promises);
|
|
279
|
-
params.Entries = results.filter(({ shouldEnqueue }) => shouldEnqueue);
|
|
279
|
+
params.Entries = results.filter(({ shouldEnqueue }) => shouldEnqueue).map(({ m }) => m);
|
|
280
280
|
if (!params.Entries.length)
|
|
281
|
-
return;
|
|
281
|
+
return { Failed: [], Successful: [] };
|
|
282
282
|
}
|
|
283
283
|
// Send them
|
|
284
284
|
const client = (0, sqs_js_1.getSQSClient)();
|
|
@@ -216,10 +216,10 @@ class JobExecutor {
|
|
|
216
216
|
else if (!this.opt.disableLog) {
|
|
217
217
|
console.log(JSON.stringify({ event: 'DELETE_MESSAGES', timestamp: start, count, qrl }));
|
|
218
218
|
}
|
|
219
|
+
// Mark batch as processed for dedup
|
|
220
|
+
await Promise.all(result.Successful.map(e => (0, dedup_js_1.dedupSuccessfullyProcessed)(this.jobsByMessageId[e.Id].message, this.opt)));
|
|
219
221
|
}
|
|
220
222
|
debug('DeleteMessageBatch returned', result);
|
|
221
|
-
// Mark batch as processed for dedup
|
|
222
|
-
await Promise.all(entries.map(e => (0, dedup_js_1.dedupSuccessfullyProcessed)(this.jobsByMessageId[e.Id], this.opt)));
|
|
223
223
|
// TODO Sentry
|
|
224
224
|
}
|
|
225
225
|
}
|
package/package.json
CHANGED
package/src/dedup.js
CHANGED
|
@@ -202,6 +202,7 @@ export async function dedupShouldEnqueueMulti (messages, opt) {
|
|
|
202
202
|
* @returns {Number} 1 if a cache key was deleted, otherwise 0
|
|
203
203
|
*/
|
|
204
204
|
export async function dedupSuccessfullyProcessed (message, opt) {
|
|
205
|
+
debug({ dedupSuccessfullyProcessed: { message, opt } })
|
|
205
206
|
const client = getCacheClient(opt)
|
|
206
207
|
const dedupId = message?.MessageAttributes?.QdoneDeduplicationId?.StringValue
|
|
207
208
|
if (dedupId) {
|
package/src/enqueue.js
CHANGED
|
@@ -275,8 +275,8 @@ export async function sendMessageBatch (qrl, messages, opt) {
|
|
|
275
275
|
if (opt.externalDedup) {
|
|
276
276
|
const promises = params.Entries.map(async m => ({ m, shouldEnqueue: await dedupShouldEnqueue(m, opt) }))
|
|
277
277
|
const results = await Promise.all(promises)
|
|
278
|
-
params.Entries = results.filter(({ shouldEnqueue }) => shouldEnqueue)
|
|
279
|
-
if (!params.Entries.length) return
|
|
278
|
+
params.Entries = results.filter(({ shouldEnqueue }) => shouldEnqueue).map(({ m }) => m)
|
|
279
|
+
if (!params.Entries.length) return { Failed: [], Successful: [] }
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
// Send them
|
|
@@ -220,11 +220,16 @@ export class JobExecutor {
|
|
|
220
220
|
} else if (!this.opt.disableLog) {
|
|
221
221
|
console.log(JSON.stringify({ event: 'DELETE_MESSAGES', timestamp: start, count, qrl }))
|
|
222
222
|
}
|
|
223
|
+
|
|
224
|
+
// Mark batch as processed for dedup
|
|
225
|
+
await Promise.all(
|
|
226
|
+
result.Successful.map(
|
|
227
|
+
e => dedupSuccessfullyProcessed(this.jobsByMessageId[e.Id].message, this.opt)
|
|
228
|
+
)
|
|
229
|
+
)
|
|
223
230
|
}
|
|
224
231
|
debug('DeleteMessageBatch returned', result)
|
|
225
232
|
|
|
226
|
-
// Mark batch as processed for dedup
|
|
227
|
-
await Promise.all(entries.map(e => dedupSuccessfullyProcessed(this.jobsByMessageId[e.Id], this.opt)))
|
|
228
233
|
|
|
229
234
|
// TODO Sentry
|
|
230
235
|
}
|