@yolo-croket-dev/core 1.4.53-slowquery.7 → 1.4.53-slowquery.8
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.
|
@@ -134,7 +134,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
134
134
|
// return data;
|
|
135
135
|
// }
|
|
136
136
|
async intercept(context, next) {
|
|
137
|
-
var _a;
|
|
137
|
+
var _a, _b;
|
|
138
138
|
const options = this.reflector.get('rpcInterceptorScope', context.getHandler());
|
|
139
139
|
const args = context.getArgs();
|
|
140
140
|
const arg = args[0];
|
|
@@ -146,9 +146,13 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
146
146
|
// const traceId = content.data.param ? content.data.param.traceId : null;
|
|
147
147
|
const isInternal = content.data.param ? content.data.param.isInternal : false;
|
|
148
148
|
const isAdmin = content.data.param ? content.data.param.isAdmin : false;
|
|
149
|
-
// const method = content.pattern;
|
|
150
149
|
const reDeliveryCount = Number(message.properties.headers['x-delivery-count']) || 0; /** 몇번 재전달되었는지 */
|
|
151
150
|
const staticRetryCount = Number(options === null || options === void 0 ? void 0 : options.messageRetryCount) || 0; /** 최대 재시도 갯수 */
|
|
151
|
+
const method = content.pattern;
|
|
152
|
+
const execInterceptor = {
|
|
153
|
+
method,
|
|
154
|
+
traceId: ((_a = content.data.param) === null || _a === void 0 ? void 0 : _a.traceId) || '-',
|
|
155
|
+
};
|
|
152
156
|
// const logParam = {
|
|
153
157
|
// traceId,
|
|
154
158
|
// method,
|
|
@@ -237,7 +241,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
237
241
|
};
|
|
238
242
|
localErrorProcessor = localErrorProcessor.bind(this);
|
|
239
243
|
/** 파일 객체 처리 */
|
|
240
|
-
(0, functions_1.reWriteFileValue)((
|
|
244
|
+
(0, functions_1.reWriteFileValue)((_b = content === null || content === void 0 ? void 0 : content.data) === null || _b === void 0 ? void 0 : _b.file);
|
|
241
245
|
if (options) {
|
|
242
246
|
if (options.maxLengthKeys && options.maxLengthKeys.length) {
|
|
243
247
|
for (const key of options.maxLengthKeys) {
|
|
@@ -266,7 +270,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
266
270
|
else {
|
|
267
271
|
// logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
|
|
268
272
|
}
|
|
269
|
-
this.gracefulShutdownService.
|
|
273
|
+
this.gracefulShutdownService.pushActiveInterceptors(execInterceptor);
|
|
270
274
|
// eslint-disable-next-line consistent-return
|
|
271
275
|
return next
|
|
272
276
|
.handle()
|
|
@@ -291,7 +295,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
291
295
|
},
|
|
292
296
|
error: localErrorProcessor,
|
|
293
297
|
}), (0, operators_1.finalize)(() => {
|
|
294
|
-
this.gracefulShutdownService.
|
|
298
|
+
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
295
299
|
}));
|
|
296
300
|
}
|
|
297
301
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { OnApplicationShutdown, OnModuleDestroy, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
interface GracefulExecInterceptor {
|
|
3
|
+
method: string;
|
|
4
|
+
traceId?: string;
|
|
5
|
+
}
|
|
2
6
|
export declare class GracefulShutdownService implements OnApplicationShutdown, OnModuleDestroy, OnApplicationBootstrap {
|
|
3
7
|
private activeInterceptors;
|
|
4
8
|
isApplicationExit: boolean;
|
|
5
9
|
onApplicationBootstrap(): void;
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
pushActiveInterceptors(execInterceptor: GracefulExecInterceptor): void;
|
|
11
|
+
popActiveInterceptors(execInterceptor: GracefulExecInterceptor): void;
|
|
8
12
|
onApplicationShutdown(signal?: string): Promise<void>;
|
|
9
13
|
onModuleDestroy(): Promise<void>;
|
|
10
14
|
}
|
|
15
|
+
export {};
|
|
@@ -35,33 +35,39 @@ const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
|
|
|
35
35
|
const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.SERVICE);
|
|
36
36
|
let GracefulShutdownService = class GracefulShutdownService {
|
|
37
37
|
constructor() {
|
|
38
|
-
this.activeInterceptors =
|
|
38
|
+
this.activeInterceptors = [];
|
|
39
39
|
this.isApplicationExit = false;
|
|
40
40
|
}
|
|
41
41
|
onApplicationBootstrap() {
|
|
42
|
-
this.activeInterceptors =
|
|
42
|
+
this.activeInterceptors = [];
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
this.activeInterceptors
|
|
44
|
+
pushActiveInterceptors(execInterceptor) {
|
|
45
|
+
this.activeInterceptors.push(execInterceptor);
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
popActiveInterceptors(execInterceptor) {
|
|
48
|
+
// eslint-disable-next-line max-len
|
|
49
|
+
this.activeInterceptors = this.activeInterceptors.filter((item) => item.method === execInterceptor.method && item.traceId === execInterceptor.traceId);
|
|
50
50
|
}
|
|
51
51
|
async onApplicationShutdown(signal) {
|
|
52
|
+
console.debug(`GracefulShutdownService.onApplicationShutdown signal=${signal}`, { traceId: 'ON_APPLICATION_SHUTDOWN' });
|
|
52
53
|
msaLogger.debug(`GracefulShutdownService.onApplicationShutdown signal=${signal}`, { traceId: 'ON_APPLICATION_SHUTDOWN' });
|
|
53
54
|
process.exit(0);
|
|
54
55
|
}
|
|
55
56
|
async onModuleDestroy() {
|
|
56
57
|
this.isApplicationExit = true;
|
|
57
58
|
msaLogger.debug('GracefulShutdownService.onModuleDestroy', { traceId: 'ON_MODULE_DESTROY' });
|
|
58
|
-
|
|
59
|
+
// eslint-disable-next-line max-len
|
|
60
|
+
msaLogger.debug('GracefulShutdownService.onModuleDestroy activeInterceptors', { traceId: 'ON_MODULE_DESTROY' }, { activeInterceptors: this.activeInterceptors });
|
|
61
|
+
// eslint-disable-next-line max-len
|
|
62
|
+
console.debug('GracefulShutdownService.onModuleDestroy activeInterceptors', { traceId: 'ON_MODULE_DESTROY' }, { activeInterceptors: this.activeInterceptors });
|
|
59
63
|
let prevExecInterceptorCount = 0;
|
|
60
|
-
while (this.activeInterceptors
|
|
61
|
-
if (prevExecInterceptorCount !== this.activeInterceptors) {
|
|
62
|
-
prevExecInterceptorCount = this.activeInterceptors;
|
|
64
|
+
while (this.activeInterceptors.length) {
|
|
65
|
+
if (prevExecInterceptorCount !== this.activeInterceptors.length) {
|
|
66
|
+
prevExecInterceptorCount = this.activeInterceptors.length;
|
|
63
67
|
// eslint-disable-next-line max-len
|
|
64
|
-
|
|
68
|
+
console.log(`GracefulShutdownService.onModuleDestroy: waiting for ${this.activeInterceptors} interceptors to finish`, { traceId: 'ON_MODULE_DESTROY' }, { activeInterceptors: this.activeInterceptors });
|
|
69
|
+
// eslint-disable-next-line max-len
|
|
70
|
+
msaLogger.debug(`GracefulShutdownService.onModuleDestroy: waiting for ${this.activeInterceptors} interceptors to finish`, { traceId: 'ON_MODULE_DESTROY' }, { activeInterceptors: this.activeInterceptors });
|
|
65
71
|
}
|
|
66
72
|
await new Promise((resolve) => {
|
|
67
73
|
setTimeout(resolve, 1000);
|