@yolo-croket-dev/core 1.7.45-slowquery.1 → 1.7.45
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.
|
@@ -16,7 +16,7 @@ export declare class AbortContext {
|
|
|
16
16
|
requestId: string;
|
|
17
17
|
} | null;
|
|
18
18
|
static disable(): void;
|
|
19
|
-
static endContext(
|
|
19
|
+
static endContext(): void;
|
|
20
20
|
static updateContext(updatedData: Partial<RequestContext>): void;
|
|
21
21
|
/**
|
|
22
22
|
* 컨텍스트가 유효한지 확인
|
|
@@ -36,16 +36,12 @@ class AbortContext {
|
|
|
36
36
|
this.asyncLocalStorage.disable();
|
|
37
37
|
}
|
|
38
38
|
// 컨텍스트 종료
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (selectContext.parentContext) {
|
|
46
|
-
return this.endContext(selectContext.parentContext);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
39
|
+
// AsyncLocalStorage는 각 async 작업의 컨텍스트를 자동으로 관리하므로
|
|
40
|
+
// 명시적으로 disable()을 호출할 필요가 없습니다.
|
|
41
|
+
// disable()을 호출하면 전체 인스턴스가 비활성화되어 이후 요청에 문제가 생깁니다.
|
|
42
|
+
static endContext() {
|
|
43
|
+
// 컨텍스트는 async 작업이 완료되면 자동으로 정리됩니다.
|
|
44
|
+
// 명시적인 cleanup은 필요하지 않습니다.
|
|
49
45
|
}
|
|
50
46
|
// 현재 컨텍스트를 업데이트하는 방법
|
|
51
47
|
static updateContext(updatedData) {
|
|
@@ -170,7 +170,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
170
170
|
isMessageAck: false,
|
|
171
171
|
};
|
|
172
172
|
context_promise_patch_1.ContextPromisePatch.patch();
|
|
173
|
-
|
|
173
|
+
let abortController = new AbortController();
|
|
174
174
|
/** consume 메시지 전부 cancel */
|
|
175
175
|
if (this.gracefulShutdownService.isApplicationExit) {
|
|
176
176
|
msaLogger.debug('RPCInterceptor isApplicationExit called', { traceId: 'IS_APPLICATION_EXIT' });
|
|
@@ -325,60 +325,46 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
325
325
|
}
|
|
326
326
|
this.gracefulShutdownService.pushActiveInterceptors(execInterceptor);
|
|
327
327
|
// eslint-disable-next-line consistent-return
|
|
328
|
-
return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () =>
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
execInterceptor.isMessageAck = true;
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
if (!noAck) {
|
|
355
|
-
execInterceptor.isMessageAck = true;
|
|
356
|
-
channel.ack(message);
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
error: localErrorProcessor,
|
|
360
|
-
}), (0, operators_1.finalize)(() => {
|
|
361
|
-
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
362
|
-
const isAborted = abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted;
|
|
363
|
-
if (context) {
|
|
364
|
-
if (isAborted) {
|
|
365
|
-
msaLogger.debug('RPCInterceptor context end', { traceId: execInterceptor.traceId }, { context: context.requestId });
|
|
366
|
-
}
|
|
367
|
-
functions_1.AbortContext.endContext();
|
|
368
|
-
// Promise 체인이 완전히 완료될 때까지 지연 후 disable
|
|
369
|
-
// setTimeout으로 여러 번 이벤트 루프를 통과시켜서 모든 Promise.then() 체인이 완료되도록 함
|
|
370
|
-
setTimeout(() => {
|
|
371
|
-
setTimeout(() => {
|
|
372
|
-
setTimeout(() => {
|
|
373
|
-
console.log('RPCInterceptor context disable');
|
|
374
|
-
functions_1.AbortContext.disable();
|
|
375
|
-
}, 0);
|
|
376
|
-
}, 0);
|
|
377
|
-
}, 0);
|
|
328
|
+
return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () => next
|
|
329
|
+
.handle()
|
|
330
|
+
.pipe((0, operators_1.timeout)({
|
|
331
|
+
each: this.DEFAULT_TIMEOUT,
|
|
332
|
+
with: () => {
|
|
333
|
+
msaLogger.error('RPCInterceptor timeout 발생', { traceId: execInterceptor.traceId }, {
|
|
334
|
+
message: this.DEFAULT_TIMEOUT_MESSAGE,
|
|
335
|
+
messagePattern: method,
|
|
336
|
+
durationMs: Date.now() - now,
|
|
337
|
+
reDeliveryCount,
|
|
338
|
+
staticRetryCount,
|
|
339
|
+
});
|
|
340
|
+
abortController.abort();
|
|
341
|
+
return (0, rxjs_1.throwError)(() => new exceptions_1.InternalServerError('TIMEOUT_ERROR', this.DEFAULT_TIMEOUT_MESSAGE));
|
|
342
|
+
},
|
|
343
|
+
}), (0, operators_1.tap)({
|
|
344
|
+
next: async (val) => {
|
|
345
|
+
val.isError = false;
|
|
346
|
+
/** 만약 응답데이터중 isRequeue가 true라면, 다시 재처리 하도록 함 */
|
|
347
|
+
if (val.data && val.data.isRequeue) {
|
|
348
|
+
channel.nack(message, false, true);
|
|
349
|
+
execInterceptor.isMessageAck = true;
|
|
350
|
+
return;
|
|
378
351
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
352
|
+
if (!noAck) {
|
|
353
|
+
execInterceptor.isMessageAck = true;
|
|
354
|
+
channel.ack(message);
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
error: localErrorProcessor,
|
|
358
|
+
}), (0, operators_1.finalize)(() => {
|
|
359
|
+
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
360
|
+
const isAborted = abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted;
|
|
361
|
+
if (isAborted) {
|
|
362
|
+
msaLogger.debug('RPCInterceptor context end', { traceId: execInterceptor.traceId }, { isAborted });
|
|
363
|
+
functions_1.AbortContext.endContext();
|
|
364
|
+
abortController = null;
|
|
365
|
+
}
|
|
366
|
+
return rxjs_1.EMPTY;
|
|
367
|
+
})));
|
|
382
368
|
}
|
|
383
369
|
};
|
|
384
370
|
exports.RPCInterceptor = RPCInterceptor;
|