@yolo-croket-dev/core 1.4.53-slowquery.7 → 1.4.53-slowquery.9
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,15 @@ 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 correlationId = message.properties.correlationId;
|
|
153
|
+
const execInterceptor = {
|
|
154
|
+
method,
|
|
155
|
+
traceId: ((_a = content.data.param) === null || _a === void 0 ? void 0 : _a.traceId) || '-',
|
|
156
|
+
correlationId,
|
|
157
|
+
};
|
|
152
158
|
// const logParam = {
|
|
153
159
|
// traceId,
|
|
154
160
|
// method,
|
|
@@ -237,7 +243,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
237
243
|
};
|
|
238
244
|
localErrorProcessor = localErrorProcessor.bind(this);
|
|
239
245
|
/** 파일 객체 처리 */
|
|
240
|
-
(0, functions_1.reWriteFileValue)((
|
|
246
|
+
(0, functions_1.reWriteFileValue)((_b = content === null || content === void 0 ? void 0 : content.data) === null || _b === void 0 ? void 0 : _b.file);
|
|
241
247
|
if (options) {
|
|
242
248
|
if (options.maxLengthKeys && options.maxLengthKeys.length) {
|
|
243
249
|
for (const key of options.maxLengthKeys) {
|
|
@@ -266,7 +272,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
266
272
|
else {
|
|
267
273
|
// logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
|
|
268
274
|
}
|
|
269
|
-
this.gracefulShutdownService.
|
|
275
|
+
this.gracefulShutdownService.pushActiveInterceptors(execInterceptor);
|
|
270
276
|
// eslint-disable-next-line consistent-return
|
|
271
277
|
return next
|
|
272
278
|
.handle()
|
|
@@ -291,7 +297,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
291
297
|
},
|
|
292
298
|
error: localErrorProcessor,
|
|
293
299
|
}), (0, operators_1.finalize)(() => {
|
|
294
|
-
this.gracefulShutdownService.
|
|
300
|
+
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
295
301
|
}));
|
|
296
302
|
}
|
|
297
303
|
};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { OnApplicationShutdown, OnModuleDestroy, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
interface GracefulExecInterceptor {
|
|
3
|
+
method: string;
|
|
4
|
+
traceId?: string;
|
|
5
|
+
correlationId: string;
|
|
6
|
+
}
|
|
2
7
|
export declare class GracefulShutdownService implements OnApplicationShutdown, OnModuleDestroy, OnApplicationBootstrap {
|
|
3
8
|
private activeInterceptors;
|
|
4
9
|
isApplicationExit: boolean;
|
|
5
10
|
onApplicationBootstrap(): void;
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
pushActiveInterceptors(execInterceptor: GracefulExecInterceptor): void;
|
|
12
|
+
popActiveInterceptors(execInterceptor: GracefulExecInterceptor): void;
|
|
8
13
|
onApplicationShutdown(signal?: string): Promise<void>;
|
|
9
14
|
onModuleDestroy(): Promise<void>;
|
|
10
15
|
}
|
|
16
|
+
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 && item.correlationId === execInterceptor.correlationId);
|
|
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);
|