qdone 2.0.53-alpha → 2.0.54-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/consumer.js
CHANGED
|
@@ -92,7 +92,7 @@ async function processMessages(queues, callback, options) {
|
|
|
92
92
|
const messages = await getMessages(qrl, opt, maxMessages);
|
|
93
93
|
if (!shutdownRequested) {
|
|
94
94
|
if (messages.length) {
|
|
95
|
-
jobExecutor.executeJobs(messages, callback, qname, qrl);
|
|
95
|
+
await jobExecutor.executeJobs(messages, callback, qname, qrl);
|
|
96
96
|
queueManager.updateIcehouse(qrl, false);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
@@ -137,7 +137,7 @@ async function checkIdle(qname, qrl, opt) {
|
|
|
137
137
|
if (cheapResult.idle === false || cheapResult.exists === false) {
|
|
138
138
|
return {
|
|
139
139
|
queue: qname.slice(opt.prefix.length),
|
|
140
|
-
cheap: cheapResult,
|
|
140
|
+
cheap: { SQS, result: cheapResult },
|
|
141
141
|
idle: cheapResult.idle,
|
|
142
142
|
exists: cheapResult.exists,
|
|
143
143
|
apiCalls: { SQS, CloudWatch: 0 }
|
|
@@ -363,6 +363,7 @@ class JobExecutor {
|
|
|
363
363
|
// Begin tracking jobs
|
|
364
364
|
const jobs = messages.map(message => this.addJob(message, callback, qname, qrl));
|
|
365
365
|
const isFifo = qrl.endsWith('.fifo');
|
|
366
|
+
const runningJobs = [];
|
|
366
367
|
// console.log(jobs)
|
|
367
368
|
// Begin executing
|
|
368
369
|
for (const [job, i] of jobs.map((job, i) => [job, i])) {
|
|
@@ -374,8 +375,9 @@ class JobExecutor {
|
|
|
374
375
|
if (nextJobIsSerial)
|
|
375
376
|
await this.runJob(job);
|
|
376
377
|
else
|
|
377
|
-
this.runJob(job);
|
|
378
|
+
runningJobs.push(this.runJob(job));
|
|
378
379
|
}
|
|
380
|
+
await Promise.all(runningJobs);
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
exports.JobExecutor = JobExecutor;
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -451,19 +451,14 @@ export async function idleQueues (argv, testHook) {
|
|
|
451
451
|
{
|
|
452
452
|
content: [
|
|
453
453
|
{ count: '1 + q + i', desc: 'q: number of queues in pattern\ni: number of idle queues' },
|
|
454
|
-
{ context: 'with --delete options', count: '1 + q + 3i', desc: 'q: number of queues in pattern\ni: number of idle queues' }
|
|
455
|
-
{ context: 'with --unpair option', count: '1 + q', desc: 'q: number of queues in pattern' },
|
|
456
|
-
{ context: 'with --unpair and --delete options', count: '1 + q + i', desc: 'q: number of queues in pattern\ni: number of idle queues' },
|
|
457
|
-
{ desc: 'NOTE: the --unpair option not cheaper if you include fail queues, because it doubles q.' }
|
|
454
|
+
{ context: 'with --delete options', count: '1 + q + 3i', desc: 'q: number of queues in pattern\ni: number of idle queues' }
|
|
458
455
|
],
|
|
459
456
|
long: true
|
|
460
457
|
},
|
|
461
458
|
{ content: 'CloudWatch API Call Complexity', raw: true, long: true },
|
|
462
459
|
{
|
|
463
460
|
content: [
|
|
464
|
-
{ count: 'min: 0 (if queue and fail queue have waiting messages)\nmax: 12q\nexpected (approximate observed): 0.5q + 12i', desc: 'q: number of queues in pattern\ni: number of idle queues' }
|
|
465
|
-
{ context: 'with --unpair option', count: 'min: 0 (if queue has waiting messages)\nmax: 6q\nexpected (approximate observed): q + 6i', desc: 'q: number of queues in pattern\ni: number of idle queues' },
|
|
466
|
-
{ desc: 'NOTE: the --unpair option not cheaper if you include fail queues, because it doubles q.' }
|
|
461
|
+
{ count: 'min: 0 (if queue and fail queue have waiting messages)\nmax: 12q\nexpected (approximate observed): 0.5q + 12i', desc: 'q: number of queues in pattern\ni: number of idle queues' }
|
|
467
462
|
],
|
|
468
463
|
long: true
|
|
469
464
|
},
|
|
@@ -479,7 +474,6 @@ export async function idleQueues (argv, testHook) {
|
|
|
479
474
|
debug('idleQueues options', options)
|
|
480
475
|
if (options.help) return Promise.resolve(console.log(getUsage(usageSections)))
|
|
481
476
|
if (!options._unknown || options._unknown.length === 0) throw new UsageError('idle-queues requres one or more <queue> arguments')
|
|
482
|
-
if (options['include-failed'] && !options.unpair) throw new UsageError('--include-failed should be used with --unpair')
|
|
483
477
|
if (options['idle-for'] < 5) throw new UsageError('--idle-for must be at least 5 minutes (CloudWatch limitation)')
|
|
484
478
|
queues = options._unknown
|
|
485
479
|
debug('queues', queues)
|
package/src/consumer.js
CHANGED
|
@@ -96,7 +96,7 @@ export async function processMessages (queues, callback, options) {
|
|
|
96
96
|
|
|
97
97
|
if (!shutdownRequested) {
|
|
98
98
|
if (messages.length) {
|
|
99
|
-
jobExecutor.executeJobs(messages, callback, qname, qrl)
|
|
99
|
+
await jobExecutor.executeJobs(messages, callback, qname, qrl)
|
|
100
100
|
queueManager.updateIcehouse(qrl, false)
|
|
101
101
|
} else {
|
|
102
102
|
// If we didn't get any, update the icehouse so we can back off
|
package/src/idleQueues.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getCloudWatchClient } from './cloudWatch.js'
|
|
|
7
7
|
import { getOptionsWithDefaults } from './defaults.js'
|
|
8
8
|
import { GetQueueAttributesCommand, DeleteQueueCommand, QueueDoesNotExist } from '@aws-sdk/client-sqs'
|
|
9
9
|
import { GetMetricStatisticsCommand } from '@aws-sdk/client-cloudwatch'
|
|
10
|
-
import { normalizeFailQueueName, normalizeDLQName, getQnameUrlPairs, fifoSuffix } from './qrlCache.js'
|
|
10
|
+
import { normalizeFailQueueName, normalizeDLQName, getQnameUrlPairs, fifoSuffix, qrlCacheSet } from './qrlCache.js'
|
|
11
11
|
import { getCache, setCache } from './cache.js'
|
|
12
12
|
// const AWS = require('aws-sdk')
|
|
13
13
|
|
|
@@ -133,7 +133,7 @@ export async function checkIdle (qname, qrl, opt) {
|
|
|
133
133
|
if (cheapResult.idle === false || cheapResult.exists === false) {
|
|
134
134
|
return {
|
|
135
135
|
queue: qname.slice(opt.prefix.length),
|
|
136
|
-
cheap: cheapResult,
|
|
136
|
+
cheap: { SQS, result: cheapResult },
|
|
137
137
|
idle: cheapResult.idle,
|
|
138
138
|
exists: cheapResult.exists,
|
|
139
139
|
apiCalls: { SQS, CloudWatch: 0 }
|
|
@@ -373,6 +373,7 @@ export class JobExecutor {
|
|
|
373
373
|
// Begin tracking jobs
|
|
374
374
|
const jobs = messages.map(message => this.addJob(message, callback, qname, qrl))
|
|
375
375
|
const isFifo = qrl.endsWith('.fifo')
|
|
376
|
+
const runningJobs = []
|
|
376
377
|
|
|
377
378
|
// console.log(jobs)
|
|
378
379
|
|
|
@@ -385,7 +386,8 @@ export class JobExecutor {
|
|
|
385
386
|
// console.log({ i, nextJobAtt: nextJob?.message?.Attributes, nextJobIsSerial })
|
|
386
387
|
// Execute serial or parallel
|
|
387
388
|
if (nextJobIsSerial) await this.runJob(job)
|
|
388
|
-
else this.runJob(job)
|
|
389
|
+
else runningJobs.push(this.runJob(job))
|
|
389
390
|
}
|
|
391
|
+
await Promise.all(runningJobs)
|
|
390
392
|
}
|
|
391
393
|
}
|