@yolo-croket-dev/core 1.7.17 → 1.7.18-slowquery.1
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.
- package/interceptors/logging-service.interceptor.js +2 -2
- package/interceptors/rpc.interceptor.d.ts +2 -0
- package/interceptors/rpc.interceptor.js +65 -8
- package/interfaces/exception.js +3 -3
- package/modules/graceful-shutdown/graceful-shutdown.module.js +2 -2
- package/modules/graceful-shutdown/graceful-shutdown.rmq.d.ts +1 -1
- package/modules/graceful-shutdown/graceful-shutdown.service.js +2 -2
- package/modules/redis.module.js +2 -2
- package/package.json +1 -1
- package/pipes/rpc-validation.pipe.js +2 -2
|
@@ -188,7 +188,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
188
188
|
}));
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
|
-
LoggingServiceInterceptor =
|
|
191
|
+
exports.LoggingServiceInterceptor = LoggingServiceInterceptor;
|
|
192
|
+
exports.LoggingServiceInterceptor = LoggingServiceInterceptor = __decorate([
|
|
192
193
|
(0, common_1.Injectable)()
|
|
193
194
|
], LoggingServiceInterceptor);
|
|
194
|
-
exports.LoggingServiceInterceptor = LoggingServiceInterceptor;
|
|
@@ -7,6 +7,8 @@ export declare class RPCInterceptor implements NestInterceptor {
|
|
|
7
7
|
private readonly gracefulShutdownService;
|
|
8
8
|
constructor(reflector: Reflector, gracefulShutdownService: GracefulShutdownService);
|
|
9
9
|
private maxLengthOverShorten;
|
|
10
|
+
/** 메시지가 재전송되었을때에, 재시도 Count가 명시되어 있지 않을때에 처리 할지 여부를 결정하는 함수 */
|
|
11
|
+
isRedeliveryMessage(replyTo: string, traceId: string): Promise<boolean>;
|
|
10
12
|
private updateMaxLengthArrayShorten;
|
|
11
13
|
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<unknown>>;
|
|
12
14
|
}
|
|
@@ -31,6 +31,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
exports.RPCInterceptor = void 0;
|
|
36
39
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -40,6 +43,7 @@ const core_1 = require("@nestjs/core");
|
|
|
40
43
|
const rxjs_1 = require("rxjs");
|
|
41
44
|
const operators_1 = require("rxjs/operators");
|
|
42
45
|
const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
|
|
46
|
+
const amqplib_1 = __importDefault(require("amqplib"));
|
|
43
47
|
// import Logger from '@yolo-croket-dev/logger';
|
|
44
48
|
const functions_1 = require("../functions");
|
|
45
49
|
const exceptions_1 = require("../exceptions");
|
|
@@ -62,6 +66,40 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
62
66
|
}
|
|
63
67
|
return data;
|
|
64
68
|
}
|
|
69
|
+
/** 메시지가 재전송되었을때에, 재시도 Count가 명시되어 있지 않을때에 처리 할지 여부를 결정하는 함수 */
|
|
70
|
+
async isRedeliveryMessage(replyTo, traceId) {
|
|
71
|
+
let connection;
|
|
72
|
+
let channel;
|
|
73
|
+
let isRedeliveryProcess = false;
|
|
74
|
+
const AMQP_URL = process.env.AMQP_URL;
|
|
75
|
+
if (!AMQP_URL || !AMQP_URL.length || !replyTo.length) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
connection = await amqplib_1.default.connect(AMQP_URL);
|
|
80
|
+
channel = await connection.createChannel();
|
|
81
|
+
const isQueueExist = await channel.checkQueue(replyTo);
|
|
82
|
+
if (isQueueExist) {
|
|
83
|
+
isRedeliveryProcess = true;
|
|
84
|
+
}
|
|
85
|
+
await channel.close();
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
const error = err;
|
|
89
|
+
const logParam = {
|
|
90
|
+
message: error.message,
|
|
91
|
+
stack: error.stack,
|
|
92
|
+
};
|
|
93
|
+
msaLogger.error('isRedeliveryMessage error', { traceId }, logParam);
|
|
94
|
+
isRedeliveryProcess = false;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
if (connection) {
|
|
98
|
+
await connection.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return isRedeliveryProcess;
|
|
102
|
+
}
|
|
65
103
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
104
|
updateMaxLengthArrayShorten(obj, path) {
|
|
67
105
|
const keys = path.split('.');
|
|
@@ -135,7 +173,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
135
173
|
// return data;
|
|
136
174
|
// }
|
|
137
175
|
async intercept(context, next) {
|
|
138
|
-
var _a, _b, _c;
|
|
176
|
+
var _a, _b, _c, _d, _e;
|
|
139
177
|
const options = this.reflector.get('rpcInterceptorScope', context.getHandler());
|
|
140
178
|
const args = context.getArgs();
|
|
141
179
|
const arg = args[0];
|
|
@@ -162,7 +200,6 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
162
200
|
return rxjs_1.EMPTY;
|
|
163
201
|
}
|
|
164
202
|
if (!staticRetryCount && reDeliveryCount > 0) {
|
|
165
|
-
// 직접 메시지가 재시도 처리가 된 경우에는 로그만 남기고 처리하지 않음
|
|
166
203
|
msaLogger.debug('RETRY_COUNT_ZERO_OR_NO_RETRY 발생 전, redelivery 발생', { traceId: ((_b = content.data.param) === null || _b === void 0 ? void 0 : _b.traceId) || 'RETRY_COUNT_ZERO_OR_NO_RETRY' }, {
|
|
167
204
|
messagePattern: method,
|
|
168
205
|
properties: message.properties,
|
|
@@ -171,9 +208,22 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
171
208
|
reDeliveryCount,
|
|
172
209
|
staticRetryCount,
|
|
173
210
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
211
|
+
const isRedeliveryMessage = await this.isRedeliveryMessage(message.properties.replyTo, execInterceptor.traceId);
|
|
212
|
+
if (!isRedeliveryMessage || reDeliveryCount > 5) {
|
|
213
|
+
msaLogger.debug('isRedeliveryMessage RETRY_COUNT_ZERO_OR_NO_RETRY false', { traceId: ((_c = content.data.param) === null || _c === void 0 ? void 0 : _c.traceId) || 'RETRY_COUNT_ZERO_OR_NO_RETRY' });
|
|
214
|
+
channel.sendToQueue(message.properties.replyTo, Buffer.from(JSON.stringify({
|
|
215
|
+
isError: true,
|
|
216
|
+
message: 'RETRY_COUNT_ZERO_OR_NO_RETRY',
|
|
217
|
+
status: 500,
|
|
218
|
+
duration: Date.now() - now,
|
|
219
|
+
arg,
|
|
220
|
+
timestamp: new Date(),
|
|
221
|
+
})), { correlationId: message.properties.correlationId });
|
|
222
|
+
channel.nack(message, false, false); /** 아마도 기본 30분 타임아웃이 지나고 새로 들어오면 발생할 예정, DLQ로 이동 */
|
|
223
|
+
message.properties.replyTo = undefined; /** replyTo가 존재하면 sendToQueue가 호출되므로, 삭제해주기 */
|
|
224
|
+
return new rxjs_1.Observable();
|
|
225
|
+
}
|
|
226
|
+
msaLogger.debug('isRedeliveryMessage RETRY_COUNT_ZERO_OR_NO_RETRY true, 재처리하여 전달토록 하기', { traceId: ((_d = content.data.param) === null || _d === void 0 ? void 0 : _d.traceId) || 'RETRY_COUNT_ZERO_OR_NO_RETRY' });
|
|
177
227
|
}
|
|
178
228
|
const noAck = message.fields.routingKey.includes('ASYNC');
|
|
179
229
|
let localErrorProcessor = async (err) => {
|
|
@@ -244,7 +294,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
244
294
|
};
|
|
245
295
|
localErrorProcessor = localErrorProcessor.bind(this);
|
|
246
296
|
/** 파일 객체 처리 */
|
|
247
|
-
(0, functions_1.reWriteFileValue)((
|
|
297
|
+
(0, functions_1.reWriteFileValue)((_e = content === null || content === void 0 ? void 0 : content.data) === null || _e === void 0 ? void 0 : _e.file);
|
|
248
298
|
if (options) {
|
|
249
299
|
if (options.maxLengthKeys && options.maxLengthKeys.length) {
|
|
250
300
|
for (const key of options.maxLengthKeys) {
|
|
@@ -297,14 +347,21 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
297
347
|
}
|
|
298
348
|
},
|
|
299
349
|
error: localErrorProcessor,
|
|
350
|
+
}), (0, operators_1.catchError)(async (err) => {
|
|
351
|
+
// timeout 에러 처리
|
|
352
|
+
msaLogger.error('Timeout occurred, requeuing message', { traceId: execInterceptor.traceId }, { error: err });
|
|
353
|
+
// 메시지를 Requeue
|
|
354
|
+
channel.nack(message, false, true);
|
|
355
|
+
// 에러를 다시 throw하여 상위에서 처리할 수 있도록 함
|
|
356
|
+
throw err;
|
|
300
357
|
}), (0, operators_1.finalize)(() => {
|
|
301
358
|
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
302
359
|
}));
|
|
303
360
|
}
|
|
304
361
|
};
|
|
305
|
-
RPCInterceptor =
|
|
362
|
+
exports.RPCInterceptor = RPCInterceptor;
|
|
363
|
+
exports.RPCInterceptor = RPCInterceptor = __decorate([
|
|
306
364
|
(0, common_1.Injectable)(),
|
|
307
365
|
__metadata("design:paramtypes", [core_1.Reflector,
|
|
308
366
|
graceful_shutdown_service_1.GracefulShutdownService])
|
|
309
367
|
], RPCInterceptor);
|
|
310
|
-
exports.RPCInterceptor = RPCInterceptor;
|
package/interfaces/exception.js
CHANGED
|
@@ -18,9 +18,10 @@ var ErrActionTypeEnum;
|
|
|
18
18
|
ErrActionTypeEnum["LEGACY_SHOW_TOAST"] = "LEGACY_SHOW_TOAST";
|
|
19
19
|
ErrActionTypeEnum["FORCE_UPDATE"] = "FORCE_UPDATE";
|
|
20
20
|
ErrActionTypeEnum["UPDATE_ACCESS_TOKEN"] = "UPDATE_ACCESS_TOKEN";
|
|
21
|
-
})(ErrActionTypeEnum
|
|
21
|
+
})(ErrActionTypeEnum || (exports.ErrActionTypeEnum = ErrActionTypeEnum = {}));
|
|
22
22
|
class ErrAction {
|
|
23
23
|
}
|
|
24
|
+
exports.ErrAction = ErrAction;
|
|
24
25
|
__decorate([
|
|
25
26
|
(0, swagger_1.ApiProperty)({
|
|
26
27
|
description: '액션 타입',
|
|
@@ -57,9 +58,9 @@ __decorate([
|
|
|
57
58
|
}),
|
|
58
59
|
__metadata("design:type", String)
|
|
59
60
|
], ErrAction.prototype, "webViewUrl", void 0);
|
|
60
|
-
exports.ErrAction = ErrAction;
|
|
61
61
|
class ErrInfo {
|
|
62
62
|
}
|
|
63
|
+
exports.ErrInfo = ErrInfo;
|
|
63
64
|
__decorate([
|
|
64
65
|
(0, swagger_1.ApiProperty)({
|
|
65
66
|
description: '에러 종류 식별자',
|
|
@@ -81,4 +82,3 @@ __decorate([
|
|
|
81
82
|
}),
|
|
82
83
|
__metadata("design:type", ErrAction)
|
|
83
84
|
], ErrInfo.prototype, "action", void 0);
|
|
84
|
-
exports.ErrInfo = ErrInfo;
|
|
@@ -11,11 +11,11 @@ const common_1 = require("@nestjs/common");
|
|
|
11
11
|
const graceful_shutdown_service_1 = require("./graceful-shutdown.service");
|
|
12
12
|
let GracefulShutdownModule = class GracefulShutdownModule {
|
|
13
13
|
};
|
|
14
|
-
GracefulShutdownModule =
|
|
14
|
+
exports.GracefulShutdownModule = GracefulShutdownModule;
|
|
15
|
+
exports.GracefulShutdownModule = GracefulShutdownModule = __decorate([
|
|
15
16
|
(0, common_1.Global)(),
|
|
16
17
|
(0, common_1.Module)({
|
|
17
18
|
providers: [graceful_shutdown_service_1.GracefulShutdownService],
|
|
18
19
|
exports: [graceful_shutdown_service_1.GracefulShutdownService],
|
|
19
20
|
})
|
|
20
21
|
], GracefulShutdownModule);
|
|
21
|
-
exports.GracefulShutdownModule = GracefulShutdownModule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RmqOptions, ServerRMQ } from '@nestjs/microservices';
|
|
2
2
|
import { Channel } from 'amqp-connection-manager';
|
|
3
3
|
import { ConsumeMessage } from 'amqplib';
|
|
4
|
-
export
|
|
4
|
+
export type GracefulRmqOptions = RmqOptions['options'] & {
|
|
5
5
|
waitingEndingHandlersTimeoutMs?: number;
|
|
6
6
|
waitingEndingHandlersIntervalMs?: number;
|
|
7
7
|
};
|
|
@@ -94,7 +94,7 @@ let GracefulShutdownService = class GracefulShutdownService {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
GracefulShutdownService =
|
|
97
|
+
exports.GracefulShutdownService = GracefulShutdownService;
|
|
98
|
+
exports.GracefulShutdownService = GracefulShutdownService = __decorate([
|
|
98
99
|
(0, common_1.Injectable)()
|
|
99
100
|
], GracefulShutdownService);
|
|
100
|
-
exports.GracefulShutdownService = GracefulShutdownService;
|
package/modules/redis.module.js
CHANGED
|
@@ -15,10 +15,10 @@ const redisProvider = {
|
|
|
15
15
|
};
|
|
16
16
|
let RedisModule = class RedisModule {
|
|
17
17
|
};
|
|
18
|
-
RedisModule =
|
|
18
|
+
exports.RedisModule = RedisModule;
|
|
19
|
+
exports.RedisModule = RedisModule = __decorate([
|
|
19
20
|
(0, common_1.Module)({
|
|
20
21
|
providers: [redisProvider],
|
|
21
22
|
exports: [redisProvider],
|
|
22
23
|
})
|
|
23
24
|
], RedisModule);
|
|
24
|
-
exports.RedisModule = RedisModule;
|
package/package.json
CHANGED
|
@@ -31,8 +31,8 @@ let ValidationPipe = class ValidationPipe {
|
|
|
31
31
|
return value;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
ValidationPipe =
|
|
34
|
+
exports.ValidationPipe = ValidationPipe;
|
|
35
|
+
exports.ValidationPipe = ValidationPipe = __decorate([
|
|
35
36
|
(0, common_1.Injectable)(),
|
|
36
37
|
__metadata("design:paramtypes", [Object])
|
|
37
38
|
], ValidationPipe);
|
|
38
|
-
exports.ValidationPipe = ValidationPipe;
|