@seidor-cloud-produtos/orbit-backend-lib 2.0.34 → 2.0.36
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.
|
@@ -36,7 +36,7 @@ class SQSScaledJobRunner {
|
|
|
36
36
|
const resp = await this.sqs.send(new client_sqs_1.ReceiveMessageCommand({
|
|
37
37
|
QueueUrl: this.queueUrl,
|
|
38
38
|
MaxNumberOfMessages: 1,
|
|
39
|
-
WaitTimeSeconds: this.options.
|
|
39
|
+
WaitTimeSeconds: this.options.waitMessagesTimeSeconds || 20,
|
|
40
40
|
}));
|
|
41
41
|
const messages = resp.Messages ?? [];
|
|
42
42
|
if (!messages.length) {
|
|
@@ -47,14 +47,14 @@ class SQSScaledJobRunner {
|
|
|
47
47
|
category: logger_1.CategoryEnum.TECHNICAL,
|
|
48
48
|
type: 'runner-without-messages',
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
continue;
|
|
51
51
|
}
|
|
52
52
|
const [rawMessage] = messages;
|
|
53
53
|
const message = SQSScaledJobRunner.parseMessage(rawMessage.Body);
|
|
54
54
|
logger_in_memory_1.default.log(`[SQSScaledJobRunner] Mensagem recebida ${JSON.stringify(message)}`);
|
|
55
55
|
const promises = [this.handler.handle(message)];
|
|
56
56
|
if (timeoutPerMessageSeconds) {
|
|
57
|
-
promises.push((0, timeout_1.
|
|
57
|
+
promises.push((0, timeout_1.sleep)(timeoutPerMessageSeconds * 1000));
|
|
58
58
|
}
|
|
59
59
|
await Promise.race(promises);
|
|
60
60
|
logger_in_memory_1.default.log('[SQSScaledJobRunner] Mensagem processada com sucesso');
|
|
@@ -82,7 +82,7 @@ class SQSScaledJobRunner {
|
|
|
82
82
|
async run() {
|
|
83
83
|
const promises = [this.process()];
|
|
84
84
|
if (this.options.processTimeoutSeconds) {
|
|
85
|
-
promises.push((0, timeout_1.
|
|
85
|
+
promises.push((0, timeout_1.sleep)(this.options.processTimeoutSeconds * 1000));
|
|
86
86
|
}
|
|
87
87
|
await Promise.race(promises);
|
|
88
88
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rejectTimeout = void 0;
|
|
3
|
+
exports.sleep = exports.rejectTimeout = void 0;
|
|
4
4
|
function rejectTimeout(timeoutMs) {
|
|
5
5
|
return new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), timeoutMs));
|
|
6
6
|
}
|
|
7
7
|
exports.rejectTimeout = rejectTimeout;
|
|
8
|
+
async function sleep(timeoutMs) {
|
|
9
|
+
return new Promise(r => setTimeout(r, timeoutMs));
|
|
10
|
+
}
|
|
11
|
+
exports.sleep = sleep;
|