qdone 2.0.17-alpha → 2.0.18-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.
|
@@ -85,21 +85,33 @@ var metricNames = [
|
|
|
85
85
|
*/
|
|
86
86
|
function _cheapIdleCheck(qname, qrl, opt) {
|
|
87
87
|
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
-
var client, cmd, data,
|
|
88
|
+
var client, cmd, data, result_1, e_1;
|
|
89
89
|
return __generator(this, function (_a) {
|
|
90
90
|
switch (_a.label) {
|
|
91
91
|
case 0:
|
|
92
|
+
_a.trys.push([0, 2, , 3]);
|
|
92
93
|
client = (0, sqs_js_1.getSQSClient)();
|
|
93
94
|
cmd = new client_sqs_1.GetQueueAttributesCommand({ AttributeNames: exports.attributeNames, QueueUrl: qrl });
|
|
94
95
|
return [4 /*yield*/, client.send(cmd)];
|
|
95
96
|
case 1:
|
|
96
97
|
data = _a.sent();
|
|
97
98
|
debug('data', data);
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
result_1 = data.Attributes;
|
|
100
|
+
result_1.queue = qname.slice(opt.prefix.length);
|
|
100
101
|
// We are idle if all the messages attributes are zero
|
|
101
|
-
|
|
102
|
-
return [2 /*return*/, { result:
|
|
102
|
+
result_1.idle = exports.attributeNames.filter(function (k) { return result_1[k] === '0'; }).length === exports.attributeNames.length;
|
|
103
|
+
return [2 /*return*/, { result: result_1, SQS: 1 }];
|
|
104
|
+
case 2:
|
|
105
|
+
e_1 = _a.sent();
|
|
106
|
+
if (e_1 instanceof client_sqs_1.QueueDoesNotExist) {
|
|
107
|
+
// Count deleted queues as idle
|
|
108
|
+
return [2 /*return*/, { idle: true, SQS: 1 }];
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
throw e_1;
|
|
112
|
+
}
|
|
113
|
+
return [3 /*break*/, 3];
|
|
114
|
+
case 3: return [2 /*return*/];
|
|
103
115
|
}
|
|
104
116
|
});
|
|
105
117
|
});
|
|
@@ -320,7 +332,7 @@ exports.processQueue = processQueue;
|
|
|
320
332
|
*/
|
|
321
333
|
function processQueuePair(qname, qrl, opt) {
|
|
322
334
|
return __awaiter(this, void 0, void 0, function () {
|
|
323
|
-
var isFifo, normalizeOptions, fqname, fqrl, result, active, fresult, idleCheckResult, factive, _a, dresult, dfresult,
|
|
335
|
+
var isFifo, normalizeOptions, fqname, fqrl, result, active, fresult, idleCheckResult, factive, _a, dresult, dfresult, e_2, deleteResult, resultIncludingDelete;
|
|
324
336
|
return __generator(this, function (_b) {
|
|
325
337
|
switch (_b.label) {
|
|
326
338
|
case 0:
|
|
@@ -385,11 +397,11 @@ function processQueuePair(qname, qrl, opt) {
|
|
|
385
397
|
}
|
|
386
398
|
})];
|
|
387
399
|
case 5:
|
|
388
|
-
|
|
400
|
+
e_2 = _b.sent();
|
|
389
401
|
// Handle the case where the fail queue has been deleted or was never
|
|
390
402
|
// created for some reason
|
|
391
|
-
if (!(
|
|
392
|
-
throw
|
|
403
|
+
if (!(e_2 instanceof client_sqs_1.QueueDoesNotExist))
|
|
404
|
+
throw e_2;
|
|
393
405
|
// Fail queue doesn't exist if we get here
|
|
394
406
|
if (opt.verbose)
|
|
395
407
|
console.error(chalk_1.default.blue('Queue ') + fqname.slice(opt.prefix.length) + chalk_1.default.blue(' does not exist.'));
|
|
@@ -269,7 +269,7 @@ var JobExecutor = /** @class */ (function () {
|
|
|
269
269
|
};
|
|
270
270
|
JobExecutor.prototype.executeJob = function (message, callback, qname, qrl) {
|
|
271
271
|
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
-
var payload, visibilityTimeout, job, oldJob, e,
|
|
272
|
+
var payload, visibilityTimeout, job, oldJob, e, queue, result, err_1;
|
|
273
273
|
return __generator(this, function (_a) {
|
|
274
274
|
switch (_a.label) {
|
|
275
275
|
case 0:
|
|
@@ -316,8 +316,8 @@ var JobExecutor = /** @class */ (function () {
|
|
|
316
316
|
_a.label = 1;
|
|
317
317
|
case 1:
|
|
318
318
|
_a.trys.push([1, 3, , 4]);
|
|
319
|
-
|
|
320
|
-
return [4 /*yield*/,
|
|
319
|
+
queue = qname.slice(this.opt.prefix.length);
|
|
320
|
+
return [4 /*yield*/, callback(queue, payload)];
|
|
321
321
|
case 2:
|
|
322
322
|
result = _a.sent();
|
|
323
323
|
debug('executeJob callback finished', { payload: payload, result: result });
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qdone",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18-alpha",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "qdone",
|
|
9
|
-
"version": "2.0.
|
|
9
|
+
"version": "2.0.18-alpha",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cloudwatch": "^3.465.0",
|
package/package.json
CHANGED
package/src/idleQueues.js
CHANGED
|
@@ -37,15 +37,24 @@ const metricNames = [
|
|
|
37
37
|
* Actual SQS call, used in conjunction with cache.
|
|
38
38
|
*/
|
|
39
39
|
export async function _cheapIdleCheck (qname, qrl, opt) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
try {
|
|
41
|
+
const client = getSQSClient()
|
|
42
|
+
const cmd = new GetQueueAttributesCommand({ AttributeNames: attributeNames, QueueUrl: qrl })
|
|
43
|
+
const data = await client.send(cmd)
|
|
44
|
+
debug('data', data)
|
|
45
|
+
const result = data.Attributes
|
|
46
|
+
result.queue = qname.slice(opt.prefix.length)
|
|
47
|
+
// We are idle if all the messages attributes are zero
|
|
48
|
+
result.idle = attributeNames.filter(k => result[k] === '0').length === attributeNames.length
|
|
49
|
+
return { result, SQS: 1 }
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (e instanceof QueueDoesNotExist) {
|
|
52
|
+
// Count deleted queues as idle
|
|
53
|
+
return { idle: true, SQS: 1 }
|
|
54
|
+
} else {
|
|
55
|
+
throw e
|
|
56
|
+
}
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
/**
|
|
@@ -242,7 +242,7 @@ export class JobExecutor {
|
|
|
242
242
|
// Execute job
|
|
243
243
|
try {
|
|
244
244
|
const queue = qname.slice(this.opt.prefix.length)
|
|
245
|
-
const result = await
|
|
245
|
+
const result = await callback(queue, payload)
|
|
246
246
|
debug('executeJob callback finished', { payload, result })
|
|
247
247
|
if (this.opt.verbose) {
|
|
248
248
|
console.error(chalk.green('SUCCESS'), message.Body)
|