@yolo-croket-dev/core 1.4.53-slowquery.2 → 1.4.53-slowquery.4
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.
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
8
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
33
|
};
|
|
@@ -15,10 +38,13 @@ const common_1 = require("@nestjs/common");
|
|
|
15
38
|
const core_1 = require("@nestjs/core");
|
|
16
39
|
const rxjs_1 = require("rxjs");
|
|
17
40
|
const operators_1 = require("rxjs/operators");
|
|
41
|
+
const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
|
|
18
42
|
// import Logger from '@yolo-croket-dev/logger';
|
|
19
43
|
const functions_1 = require("../functions");
|
|
20
44
|
const exceptions_1 = require("../exceptions");
|
|
21
45
|
const graceful_shutdown_service_1 = require("../modules/graceful-shutdown/graceful-shutdown.service");
|
|
46
|
+
// const logger = Logger.createLogger('RPCInterceptor');
|
|
47
|
+
const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.SERVICE);
|
|
22
48
|
// const MAX_CUT_LENGTH = 500;
|
|
23
49
|
const MAX_LENGTH = 300;
|
|
24
50
|
let RPCInterceptor = class RPCInterceptor {
|
|
@@ -127,6 +153,12 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
127
153
|
// traceId,
|
|
128
154
|
// method,
|
|
129
155
|
// };
|
|
156
|
+
/** consume 메시지 전부 cancel */
|
|
157
|
+
if (this.gracefulShutdownService.isApplicationExit) {
|
|
158
|
+
msaLogger.debug('RPCInterceptor isApplicationExit called', { traceId: 'IS_APPLICATION_EXIT' });
|
|
159
|
+
channel.cancel(message.fields.consumerTag);
|
|
160
|
+
return new rxjs_1.Observable();
|
|
161
|
+
}
|
|
130
162
|
if (!staticRetryCount && reDeliveryCount > 0) {
|
|
131
163
|
channel.sendToQueue(message.properties.replyTo, Buffer.from(JSON.stringify({
|
|
132
164
|
isError: true,
|
|
@@ -234,6 +266,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
234
266
|
else {
|
|
235
267
|
// logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
|
|
236
268
|
}
|
|
269
|
+
msaLogger.debug('RPCInterceptor IncActiveInterceptors called', { traceId: 'INC_RPC_ACTIVE_INTERCEPTORS' });
|
|
237
270
|
this.gracefulShutdownService.incActiveInterceptors();
|
|
238
271
|
// eslint-disable-next-line consistent-return
|
|
239
272
|
return next
|
|
@@ -258,6 +291,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
258
291
|
},
|
|
259
292
|
error: localErrorProcessor,
|
|
260
293
|
}), (0, operators_1.finalize)(() => {
|
|
294
|
+
msaLogger.debug('RPCInterceptor DecActiveInterceptors called', { traceId: 'DEC_RPC_ACTIVE_INTERCEPTORS' });
|
|
261
295
|
this.gracefulShutdownService.decActiveInterceptors();
|
|
262
296
|
}));
|
|
263
297
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { OnApplicationShutdown, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
-
export declare class GracefulShutdownService implements OnApplicationShutdown, OnModuleDestroy {
|
|
1
|
+
import { OnApplicationShutdown, OnModuleDestroy, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
export declare class GracefulShutdownService implements OnApplicationShutdown, OnModuleDestroy, OnApplicationBootstrap {
|
|
3
3
|
private activeInterceptors;
|
|
4
|
+
isApplicationExit: boolean;
|
|
5
|
+
onApplicationBootstrap(): void;
|
|
4
6
|
incActiveInterceptors(): void;
|
|
5
7
|
decActiveInterceptors(): void;
|
|
6
8
|
onApplicationShutdown(signal?: string): Promise<void>;
|
|
@@ -36,6 +36,11 @@ const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.SERVICE);
|
|
|
36
36
|
let GracefulShutdownService = class GracefulShutdownService {
|
|
37
37
|
constructor() {
|
|
38
38
|
this.activeInterceptors = 0;
|
|
39
|
+
this.isApplicationExit = false;
|
|
40
|
+
}
|
|
41
|
+
onApplicationBootstrap() {
|
|
42
|
+
msaLogger.debug('GracefulShutdownService.onApplicationBootstrap', { traceId: 'ON_APPLICATION_BOOTSTRAP' });
|
|
43
|
+
this.activeInterceptors = 0;
|
|
39
44
|
}
|
|
40
45
|
incActiveInterceptors() {
|
|
41
46
|
this.activeInterceptors += 1;
|
|
@@ -46,7 +51,10 @@ let GracefulShutdownService = class GracefulShutdownService {
|
|
|
46
51
|
msaLogger.debug(`GracefulShutdownService.decActiveInterceptors: ${this.activeInterceptors}`, { traceId: 'DEC_ACTIVE_INTERCEPTORS' });
|
|
47
52
|
}
|
|
48
53
|
async onApplicationShutdown(signal) {
|
|
54
|
+
this.isApplicationExit = true;
|
|
49
55
|
msaLogger.debug(`GracefulShutdownService.onApplicationShutdown: ${signal}`, { traceId: 'ON_APPLICATION_SHUTDOWN' });
|
|
56
|
+
// eslint-disable-next-line max-len
|
|
57
|
+
msaLogger.debug(`GracefulShutdownService.onApplicationShutdown: activeInterceptors=${this.activeInterceptors}`, { traceId: 'ON_APPLICATION_SHUTDOWN' });
|
|
50
58
|
while (this.activeInterceptors > 0) {
|
|
51
59
|
// eslint-disable-next-line max-len
|
|
52
60
|
msaLogger.debug(`GracefulShutdownService.onApplicationShutdown: waiting for ${this.activeInterceptors} interceptors to finish`, { traceId: 'ON_APPLICATION_SHUTDOWN' });
|
|
@@ -56,7 +64,9 @@ let GracefulShutdownService = class GracefulShutdownService {
|
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
async onModuleDestroy() {
|
|
67
|
+
this.isApplicationExit = true;
|
|
59
68
|
msaLogger.debug('GracefulShutdownService.onModuleDestroy', { traceId: 'ON_MODULE_DESTROY' });
|
|
69
|
+
msaLogger.debug(`GracefulShutdownService.onModuleDestroy: activeInterceptors=${this.activeInterceptors}`, { traceId: 'ON_MODULE_DESTROY' });
|
|
60
70
|
while (this.activeInterceptors > 0) {
|
|
61
71
|
// eslint-disable-next-line max-len
|
|
62
72
|
msaLogger.debug(`GracefulShutdownService.onModuleDestroy: waiting for ${this.activeInterceptors} interceptors to finish`, { traceId: 'ON_MODULE_DESTROY' });
|