@seidor-cloud-produtos/orbit-backend-lib 2.0.43 → 2.0.44
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.
|
@@ -32,14 +32,10 @@ class LoggerGateway {
|
|
|
32
32
|
return acceptValues;
|
|
33
33
|
}
|
|
34
34
|
async log(data, props, options) {
|
|
35
|
-
const buildedProps = this.buildProps(
|
|
36
|
-
const
|
|
37
|
-
const matchedKey = genericKeys?.find(key => new RegExp(`${LoggerGateway.cacheKey}:(${props?.type}|\\**)-(${props?.actor}|\\**)`).test(key));
|
|
38
|
-
const cachedValue = matchedKey
|
|
39
|
-
? await this.cache.get(matchedKey)
|
|
40
|
-
: types_1.LOG_LEVEL.error;
|
|
35
|
+
const buildedProps = this.buildProps();
|
|
36
|
+
const cachedValue = await this.cache.get(`${LoggerGateway.cacheKey}:${props?.type}|*-${props?.actor}|*`);
|
|
41
37
|
const acceptValues = LoggerGateway.buildAcceptLogLevelValues(cachedValue);
|
|
42
|
-
if (
|
|
38
|
+
if (props?.category === CategoryEnum.BUSINESS ||
|
|
43
39
|
acceptValues.includes(buildedProps.level || types_1.LOG_LEVEL.info)) {
|
|
44
40
|
return await this.register(data, buildedProps, options);
|
|
45
41
|
}
|
|
@@ -5,7 +5,10 @@ export declare class SQSScaledJobRunner {
|
|
|
5
5
|
private readonly queueUrl;
|
|
6
6
|
private readonly options;
|
|
7
7
|
private sqs;
|
|
8
|
+
private timedOut;
|
|
8
9
|
constructor(handler: Handler, queueUrl: string, options: SQSScaledJobOptions);
|
|
9
10
|
private static parseMessage;
|
|
11
|
+
process(): Promise<void>;
|
|
12
|
+
private timeout;
|
|
10
13
|
run(): Promise<void>;
|
|
11
14
|
}
|
|
@@ -12,6 +12,7 @@ class SQSScaledJobRunner {
|
|
|
12
12
|
queueUrl;
|
|
13
13
|
options;
|
|
14
14
|
sqs;
|
|
15
|
+
timedOut = false;
|
|
15
16
|
constructor(handler, queueUrl, options) {
|
|
16
17
|
this.handler = handler;
|
|
17
18
|
this.queueUrl = queueUrl;
|
|
@@ -27,11 +28,11 @@ class SQSScaledJobRunner {
|
|
|
27
28
|
}
|
|
28
29
|
return JSON.parse(rawMessage);
|
|
29
30
|
}
|
|
30
|
-
async
|
|
31
|
+
async process() {
|
|
31
32
|
let consumedMessages = 0;
|
|
32
33
|
const simultaneity = this.handler.getSimultaneity();
|
|
33
34
|
const timeoutPerMessageSeconds = this.handler.getTimeoutPerMessageSeconds();
|
|
34
|
-
while (consumedMessages < simultaneity) {
|
|
35
|
+
while (consumedMessages < simultaneity && this.timedOut === false) {
|
|
35
36
|
try {
|
|
36
37
|
const resp = await this.sqs.send(new client_sqs_1.ReceiveMessageCommand({
|
|
37
38
|
QueueUrl: this.queueUrl,
|
|
@@ -79,5 +80,16 @@ class SQSScaledJobRunner {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}
|
|
83
|
+
async timeout(timeoutSeconds) {
|
|
84
|
+
await (0, timeout_1.sleep)(timeoutSeconds * 1000);
|
|
85
|
+
this.timedOut = true;
|
|
86
|
+
}
|
|
87
|
+
async run() {
|
|
88
|
+
const promises = [this.process()];
|
|
89
|
+
if (this.options.processTimeoutSeconds) {
|
|
90
|
+
promises.push(this.timeout(this.options.processTimeoutSeconds));
|
|
91
|
+
}
|
|
92
|
+
await Promise.race(promises);
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
exports.SQSScaledJobRunner = SQSScaledJobRunner;
|