@yolo-croket-dev/core 1.4.52-jun.12 → 1.4.52-jun.13
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.
|
@@ -30,10 +30,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.LoggingServiceInterceptor = void 0;
|
|
33
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
33
34
|
/* eslint-disable no-param-reassign */
|
|
34
35
|
const common_1 = require("@nestjs/common");
|
|
35
36
|
const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
|
|
36
37
|
const operators_1 = require("rxjs/operators");
|
|
38
|
+
const { SERVER_NAME } = process.env;
|
|
37
39
|
const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.SERVICE);
|
|
38
40
|
const MAX_CUT_LENGTH = 500;
|
|
39
41
|
let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
@@ -70,7 +72,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
70
72
|
intercept(context, next) {
|
|
71
73
|
var _a;
|
|
72
74
|
const now = Date.now();
|
|
73
|
-
const args = context.getArgs();
|
|
75
|
+
// const args = context.getArgs();
|
|
74
76
|
const rmqContext = context.switchToRpc().getContext();
|
|
75
77
|
const channel = rmqContext.getChannelRef();
|
|
76
78
|
const originalMessage = rmqContext.getMessage();
|
|
@@ -79,18 +81,13 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
79
81
|
console.log('originalMessage.properties', originalMessage.properties);
|
|
80
82
|
console.log('originalMessage.properties.headers', originalMessage.properties.headers);
|
|
81
83
|
const originalcontent = originalMessage.content;
|
|
82
|
-
const
|
|
83
|
-
console.log('originalcontent2', originalcontent2);
|
|
84
|
-
originalcontent2.data.param.from = 'zzz';
|
|
85
|
-
originalMessage.content = Buffer.from(JSON.stringify(originalcontent2));
|
|
86
|
-
const rmq = args[1];
|
|
87
|
-
const ctx = context.switchToHttp();
|
|
88
|
-
const request = ctx.getRequest();
|
|
89
|
-
const message = rmq.getMessage();
|
|
90
|
-
// const now = Date.now();
|
|
91
|
-
const content = JSON.parse(message.content.toString());
|
|
84
|
+
const content = JSON.parse(originalcontent.toString());
|
|
92
85
|
const traceId = content.data.param ? content.data.param.traceId : '-';
|
|
93
86
|
const from = ((_a = content.data.param) === null || _a === void 0 ? void 0 : _a.from) || '-';
|
|
87
|
+
content.data.param.from = `${SERVER_NAME}: ${content.pattern}`;
|
|
88
|
+
originalMessage.content = Buffer.from(JSON.stringify(content));
|
|
89
|
+
const ctx = context.switchToHttp();
|
|
90
|
+
const request = ctx.getRequest();
|
|
94
91
|
msaLogger.printInputInterceptorService({
|
|
95
92
|
traceId,
|
|
96
93
|
messageBrokerInfo: {
|
|
@@ -98,9 +95,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
98
95
|
payload: JSON.stringify(this.keyCutter(JSON.stringify(request.payload))),
|
|
99
96
|
},
|
|
100
97
|
paramInfo: request.param,
|
|
101
|
-
traceInfo: {
|
|
102
|
-
from,
|
|
103
|
-
}
|
|
98
|
+
traceInfo: { from },
|
|
104
99
|
});
|
|
105
100
|
return next.handle()
|
|
106
101
|
.pipe((0, operators_1.tap)(() => {
|
|
@@ -116,9 +111,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
116
111
|
messagePatten: content.pattern,
|
|
117
112
|
payload: JSON.stringify(this.keyCutter(JSON.stringify(request.payload))),
|
|
118
113
|
},
|
|
119
|
-
traceInfo: {
|
|
120
|
-
from,
|
|
121
|
-
}
|
|
114
|
+
traceInfo: { from },
|
|
122
115
|
});
|
|
123
116
|
})).pipe((0, operators_1.catchError)((error) => {
|
|
124
117
|
msaLogger.printExceptionFliterService({
|
|
@@ -133,9 +126,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
133
126
|
messagePatten: content.pattern,
|
|
134
127
|
payload: JSON.stringify(this.keyCutter(JSON.stringify(request.payload))),
|
|
135
128
|
},
|
|
136
|
-
traceInfo: {
|
|
137
|
-
from,
|
|
138
|
-
}
|
|
129
|
+
traceInfo: { from },
|
|
139
130
|
});
|
|
140
131
|
const elapsed = Date.now() - now;
|
|
141
132
|
msaLogger.printOutService({
|
|
@@ -148,9 +139,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
|
|
|
148
139
|
messagePatten: content.pattern,
|
|
149
140
|
payload: JSON.stringify(this.keyCutter(JSON.stringify(request.payload))),
|
|
150
141
|
},
|
|
151
|
-
traceInfo: {
|
|
152
|
-
from,
|
|
153
|
-
}
|
|
142
|
+
traceInfo: { from },
|
|
154
143
|
});
|
|
155
144
|
throw error;
|
|
156
145
|
}));
|
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RPCInterceptor = void 0;
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
14
|
/* eslint-disable no-param-reassign */
|
|
14
15
|
const common_1 = require("@nestjs/common");
|
|
15
16
|
const core_1 = require("@nestjs/core");
|
|
@@ -165,7 +166,10 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
165
166
|
errMessage,
|
|
166
167
|
errAction,
|
|
167
168
|
};
|
|
168
|
-
if (!Number.isNaN(staticRetryCount)
|
|
169
|
+
if (!Number.isNaN(staticRetryCount)
|
|
170
|
+
&& staticRetryCount
|
|
171
|
+
&& err.isRetry !== false) {
|
|
172
|
+
/** 재시도 로직이 필요한 경우, 0보다 커야 정의된것. 기본값이 0, isRetry값이 false로 정의된 에러가 아니라면 전부 재시도 */
|
|
169
173
|
if (reDeliveryCount <= (staticRetryCount - 1)) { /** 재시도 횟수가 있고, 재시도 횟수보다 적을 경우, 0부터 카운팅 되므로 -1 */
|
|
170
174
|
channel.nack(message, false, true);
|
|
171
175
|
message.properties.replyTo = undefined; /** replyTo가 존재하면 sendToQueue가 호출되므로, 삭제해주기 */
|