@yolo-croket-dev/core 1.10.0-jun.2-beta.1 → 1.10.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0
4
+
5
+ - 비회원 인증 로그 마스킹·검증 오류 보호·재시도 정보 필드를 정식 발행합니다.
6
+ - 기존 1.9.14의 AMQP timeout, ACK/NACK 옵션, RabbitMQ 연결 이름 설정을 보존합니다.
7
+ - 소비 서비스에서 사용하던 1.10.0-jun.2의 gRPC metadata·예외 처리와 포트 파싱을 유지합니다.
8
+
3
9
  ## 1.10.0-jun.2-beta.1
4
10
 
5
11
  - 현재 소비 버전 1.10.0-jun.2의 gRPC metadata 및 예외 처리 동작을 유지합니다.
@@ -152,7 +152,7 @@ let GrpcExceptionFilter = class GrpcExceptionFilter extends microservices_1.Base
152
152
  }
153
153
  }
154
154
  };
155
- GrpcExceptionFilter = __decorate([
155
+ exports.GrpcExceptionFilter = GrpcExceptionFilter;
156
+ exports.GrpcExceptionFilter = GrpcExceptionFilter = __decorate([
156
157
  (0, common_1.Catch)()
157
158
  ], GrpcExceptionFilter);
158
- exports.GrpcExceptionFilter = GrpcExceptionFilter;
@@ -17,11 +17,18 @@ class HttpExceptionCustom extends common_1.HttpException {
17
17
  }
18
18
  }
19
19
  exports.HttpExceptionCustom = HttpExceptionCustom;
20
+ function resolveAmqpTimeout(timeoutMs) {
21
+ if (typeof timeoutMs !== 'number' || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
22
+ return DEFAULT_TIMEOUT;
23
+ }
24
+ return Math.min(timeoutMs, DEFAULT_TIMEOUT);
25
+ }
20
26
  async function AmqpHandler(client, messagePattern, payload) {
21
- var _a, _b, _c, _d;
27
+ var _a, _b, _c, _d, _e;
22
28
  let data;
29
+ const timeoutMs = resolveAmqpTimeout((_a = payload === null || payload === void 0 ? void 0 : payload.param) === null || _a === void 0 ? void 0 : _a.timeout);
23
30
  try {
24
- data = await (0, rxjs_1.lastValueFrom)(client.send(messagePattern, payload).pipe((0, operators_1.timeout)(DEFAULT_TIMEOUT)));
31
+ data = await (0, rxjs_1.lastValueFrom)(client.send(messagePattern, payload).pipe((0, operators_1.timeout)(timeoutMs)));
25
32
  if (data.isError) {
26
33
  const status = data.status || 500;
27
34
  const subMessage = data.subMessage;
@@ -29,7 +36,7 @@ async function AmqpHandler(client, messagePattern, payload) {
29
36
  * 파일 객체 처리
30
37
  * 다른 서비스에서 이미 처리가 될 수 있음
31
38
  * */
32
- (0, _1.reWriteFileValue)((_a = data === null || data === void 0 ? void 0 : data.arg) === null || _a === void 0 ? void 0 : _a.file);
39
+ (0, _1.reWriteFileValue)((_b = data === null || data === void 0 ? void 0 : data.arg) === null || _b === void 0 ? void 0 : _b.file);
33
40
  const errInfo = data.errInfo ? data.errInfo : {
34
41
  message: data.errMessage,
35
42
  type: data.errType,
@@ -50,7 +57,7 @@ async function AmqpHandler(client, messagePattern, payload) {
50
57
  catch (err) {
51
58
  if (typeof err === 'string' && err.includes('There is no matching message handler defined in the remote service.')) {
52
59
  msaLogger.error('NOT_EXISTS_MESSAGE_PATTERN', {
53
- traceId: ((_b = payload === null || payload === void 0 ? void 0 : payload.param) === null || _b === void 0 ? void 0 : _b.traceId) || '-',
60
+ traceId: ((_c = payload === null || payload === void 0 ? void 0 : payload.param) === null || _c === void 0 ? void 0 : _c.traceId) || '-',
54
61
  errInfo: {
55
62
  errType: 'NOT_EXISTS_MESSAGE_PATTERN',
56
63
  message: `${messagePattern} 해당 메시지 패턴은 존재하지 않습니다.`,
@@ -64,7 +71,7 @@ async function AmqpHandler(client, messagePattern, payload) {
64
71
  }
65
72
  else if (err instanceof rxjs_1.TimeoutError || err.message === DEFAULT_TIMEOUT_MESSAGE) {
66
73
  msaLogger.error('TIMEOUT_ERROR', {
67
- traceId: ((_c = payload === null || payload === void 0 ? void 0 : payload.param) === null || _c === void 0 ? void 0 : _c.traceId) || '-',
74
+ traceId: ((_d = payload === null || payload === void 0 ? void 0 : payload.param) === null || _d === void 0 ? void 0 : _d.traceId) || '-',
68
75
  errInfo: {
69
76
  errType: 'TIMEOUT_ERROR',
70
77
  message: DEFAULT_TIMEOUT_MESSAGE,
@@ -77,7 +84,7 @@ async function AmqpHandler(client, messagePattern, payload) {
77
84
  });
78
85
  }
79
86
  else {
80
- msaLogger.warn('AMQP_HANDLER_ERROR', { traceId: ((_d = payload === null || payload === void 0 ? void 0 : payload.param) === null || _d === void 0 ? void 0 : _d.traceId) || '-' }, { err });
87
+ msaLogger.warn('AMQP_HANDLER_ERROR', { traceId: ((_e = payload === null || payload === void 0 ? void 0 : payload.param) === null || _e === void 0 ? void 0 : _e.traceId) || '-' }, { err });
81
88
  throw err;
82
89
  }
83
90
  }
@@ -1,7 +1,7 @@
1
1
  import { Metadata } from '@grpc/grpc-js';
2
2
  import { AbstractParam } from '../interfaces';
3
3
  export declare const GRPC_PARAM_METADATA_KEY = "param";
4
- export declare type GrpcParamMetadata = AbstractParam;
4
+ export type GrpcParamMetadata = AbstractParam;
5
5
  /**
6
6
  * @author jun
7
7
  * @description gRPC metadata에 AMQP param 호환 컨텍스트를 저장합니다.
@@ -220,7 +220,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
220
220
  }));
221
221
  }
222
222
  };
223
- LoggingServiceInterceptor = __decorate([
223
+ exports.LoggingServiceInterceptor = LoggingServiceInterceptor;
224
+ exports.LoggingServiceInterceptor = LoggingServiceInterceptor = __decorate([
224
225
  (0, common_1.Injectable)()
225
226
  ], LoggingServiceInterceptor);
226
- exports.LoggingServiceInterceptor = LoggingServiceInterceptor;
@@ -370,9 +370,9 @@ let RPCInterceptor = class RPCInterceptor {
370
370
  })));
371
371
  }
372
372
  };
373
- RPCInterceptor = __decorate([
373
+ exports.RPCInterceptor = RPCInterceptor;
374
+ exports.RPCInterceptor = RPCInterceptor = __decorate([
374
375
  (0, common_1.Injectable)(),
375
376
  __metadata("design:paramtypes", [core_1.Reflector,
376
377
  graceful_shutdown_service_1.GracefulShutdownService])
377
378
  ], RPCInterceptor);
378
- exports.RPCInterceptor = RPCInterceptor;
@@ -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 = exports.ErrActionTypeEnum || (exports.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: '에러 종류 식별자',
@@ -102,4 +103,3 @@ __decorate([
102
103
  }),
103
104
  __metadata("design:type", Number)
104
105
  ], ErrInfo.prototype, "retryAfterSeconds", void 0);
105
- exports.ErrInfo = ErrInfo;
@@ -21,4 +21,4 @@ var LogLevelEnum;
21
21
  LogLevelEnum["DEBUG"] = "debug";
22
22
  LogLevelEnum["WARN"] = "warn";
23
23
  LogLevelEnum["ERROR"] = "error";
24
- })(LogLevelEnum = exports.LogLevelEnum || (exports.LogLevelEnum = {}));
24
+ })(LogLevelEnum || (exports.LogLevelEnum = LogLevelEnum = {}));
@@ -1,6 +1,10 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { LogLevelEnum } from './log-level.enum';
3
3
  import type { ErrAction } from './exception';
4
+ export declare enum MsaExceptionMessageAckBehaviorEnum {
5
+ ACK = "ACK",
6
+ NACK = "NACK"
7
+ }
4
8
  export interface MsaExceptionOption {
5
9
  /**
6
10
  * 로그 레벨
@@ -8,6 +12,12 @@ export interface MsaExceptionOption {
8
12
  * - 기본값은 ERROR 입니다.
9
13
  * */
10
14
  logErrorLevel?: LogLevelEnum;
15
+ /**
16
+ * 메시지 consumer 실패 시 ACK/NACK override 옵션
17
+ * - 현재는 amqp-rabbit-mq subscribe consumer에서만 해석합니다.
18
+ * - option이 없으면 consumer handler의 기본 errorBehavior를 따릅니다.
19
+ */
20
+ messageAckBehavior?: MsaExceptionMessageAckBehaviorEnum;
11
21
  }
12
22
  /**
13
23
  * @author jun
@@ -27,7 +37,7 @@ export interface MsaException {
27
37
  errOption?: MsaExceptionOption;
28
38
  }
29
39
  /** HttpException과 MsaException을 결합한 타입 */
30
- export declare type MsaHttpException = MsaException & HttpException;
40
+ export type MsaHttpException = MsaException & HttpException;
31
41
  /**
32
42
  * @description MsaException 타입 가드
33
43
  * @param error 검사할 에러 객체
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMsaException = void 0;
3
+ exports.isMsaException = exports.MsaExceptionMessageAckBehaviorEnum = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
+ var MsaExceptionMessageAckBehaviorEnum;
6
+ (function (MsaExceptionMessageAckBehaviorEnum) {
7
+ MsaExceptionMessageAckBehaviorEnum["ACK"] = "ACK";
8
+ MsaExceptionMessageAckBehaviorEnum["NACK"] = "NACK";
9
+ })(MsaExceptionMessageAckBehaviorEnum || (exports.MsaExceptionMessageAckBehaviorEnum = MsaExceptionMessageAckBehaviorEnum = {}));
5
10
  /**
6
11
  * @description MsaException 타입 가드
7
12
  * @param error 검사할 에러 객체
@@ -48,7 +48,8 @@ let GracefulShutdownModule = class GracefulShutdownModule {
48
48
  msaLogger.info('GracefulShutdownService.onModuleDestroy: all interceptors finished, shutting down', { traceId: 'ON_MODULE_DESTROY' });
49
49
  }
50
50
  };
51
- GracefulShutdownModule = __decorate([
51
+ exports.GracefulShutdownModule = GracefulShutdownModule;
52
+ exports.GracefulShutdownModule = GracefulShutdownModule = __decorate([
52
53
  (0, common_1.Global)(),
53
54
  (0, common_1.Module)({
54
55
  providers: [graceful_shutdown_service_1.GracefulShutdownService],
@@ -56,4 +57,3 @@ GracefulShutdownModule = __decorate([
56
57
  }),
57
58
  __metadata("design:paramtypes", [graceful_shutdown_service_1.GracefulShutdownService])
58
59
  ], GracefulShutdownModule);
59
- exports.GracefulShutdownModule = GracefulShutdownModule;
@@ -1,10 +1,16 @@
1
- import { RmqOptions, ServerRMQ } from '@nestjs/microservices';
2
- import { Channel } from 'amqp-connection-manager';
3
- import { ConsumeMessage } from 'amqplib';
4
- export declare type GracefulRmqOptions = RmqOptions['options'] & {
1
+ import { ServerRMQ } from '@nestjs/microservices';
2
+ import type { RmqOptions } from '@nestjs/microservices';
3
+ import type { Channel } from 'amqp-connection-manager';
4
+ import type { ConsumeMessage } from 'amqplib';
5
+ export type GracefulRmqOptions = RmqOptions['options'] & {
5
6
  waitingEndingHandlersTimeoutMs?: number;
6
7
  waitingEndingHandlersIntervalMs?: number;
7
8
  };
9
+ /**
10
+ * @author jun
11
+ * @description RabbitMQ 연결 식별 정보와 graceful shutdown을 제공하는 RMQ 서버
12
+ * @process 연결 옵션에 추적 가능한 connection_name을 추가한 뒤 메시지 종료를 보장한다.
13
+ */
8
14
  export declare class GracefulServerRMQ extends ServerRMQ {
9
15
  protected readonly options: GracefulRmqOptions;
10
16
  protected runningMessages: number;
@@ -1,18 +1,67 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.GracefulServerRMQ = void 0;
4
7
  const microservices_1 = require("@nestjs/microservices");
8
+ const os_1 = __importDefault(require("os"));
5
9
  const node_util_1 = require("node:util");
6
10
  const sleep = (0, node_util_1.promisify)(setTimeout);
7
11
  const RMQ_DEFAULT_WAITING_ENDING_HANDLERS_TIMEOUT_MS = 5000;
8
12
  const RMQ_DEFAULT_WAITING_ENDING_HANDLERS_INTERVAL_MS = 500;
13
+ const RMQ_UNKNOWN_CONNECTION_IDENTITY = 'unknown';
14
+ function createRmqConnectionName(queue) {
15
+ const environment = process.env.ENV || process.env.NODE_ENV || RMQ_UNKNOWN_CONNECTION_IDENTITY;
16
+ const owner = process.env.RMQ_OWNER || process.env.USER || process.env.USERNAME || RMQ_UNKNOWN_CONNECTION_IDENTITY;
17
+ return [
18
+ queue || RMQ_UNKNOWN_CONNECTION_IDENTITY,
19
+ environment,
20
+ owner,
21
+ os_1.default.hostname(),
22
+ `pid-${process.pid}`,
23
+ ].join('/');
24
+ }
25
+ function addRmqConnectionName(options) {
26
+ var _a;
27
+ const connectionOptions = (_a = options.socketOptions) === null || _a === void 0 ? void 0 : _a.connectionOptions;
28
+ const configuredClientProperties = connectionOptions === null || connectionOptions === void 0 ? void 0 : connectionOptions.clientProperties;
29
+ const clientProperties = configuredClientProperties
30
+ && typeof configuredClientProperties === 'object'
31
+ && !Array.isArray(configuredClientProperties)
32
+ ? configuredClientProperties
33
+ : {};
34
+ const configuredConnectionName = clientProperties.connection_name;
35
+ const connectionName = typeof configuredConnectionName === 'string' && configuredConnectionName.trim()
36
+ ? configuredConnectionName
37
+ : createRmqConnectionName(options.queue);
38
+ return {
39
+ ...options,
40
+ socketOptions: {
41
+ ...options.socketOptions,
42
+ connectionOptions: {
43
+ ...connectionOptions,
44
+ clientProperties: {
45
+ ...clientProperties,
46
+ connection_name: connectionName,
47
+ },
48
+ },
49
+ },
50
+ };
51
+ }
52
+ /**
53
+ * @author jun
54
+ * @description RabbitMQ 연결 식별 정보와 graceful shutdown을 제공하는 RMQ 서버
55
+ * @process 연결 옵션에 추적 가능한 connection_name을 추가한 뒤 메시지 종료를 보장한다.
56
+ */
9
57
  class GracefulServerRMQ extends microservices_1.ServerRMQ {
10
58
  constructor(options) {
11
- super(options);
12
- this.options = options;
59
+ const optionsWithConnectionName = addRmqConnectionName(options);
60
+ super(optionsWithConnectionName);
13
61
  this.runningMessages = 0;
14
62
  this.closing = false;
15
63
  this.consumerTag = null;
64
+ this.options = optionsWithConnectionName;
16
65
  this.waitingEndingHandlersTimeoutMs = this.getOptionsProp(this.options, 'waitingEndingHandlersTimeoutMs')
17
66
  || RMQ_DEFAULT_WAITING_ENDING_HANDLERS_TIMEOUT_MS;
18
67
  this.waitingEndingHandlersIntervalMs = this.getOptionsProp(this.options, 'waitingEndingHandlersIntervalMs')
@@ -133,7 +133,7 @@ let GracefulShutdownService = class GracefulShutdownService {
133
133
  });
134
134
  }
135
135
  };
136
- GracefulShutdownService = __decorate([
136
+ exports.GracefulShutdownService = GracefulShutdownService;
137
+ exports.GracefulShutdownService = GracefulShutdownService = __decorate([
137
138
  (0, common_1.Injectable)()
138
139
  ], GracefulShutdownService);
139
- exports.GracefulShutdownService = GracefulShutdownService;
@@ -15,10 +15,10 @@ const redisProvider = {
15
15
  };
16
16
  let RedisModule = class RedisModule {
17
17
  };
18
- RedisModule = __decorate([
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.10.0-jun.2-beta.1",
3
+ "version": "1.10.0",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",
@@ -36,8 +36,8 @@ let ValidationPipe = class ValidationPipe {
36
36
  return value;
37
37
  }
38
38
  };
39
- ValidationPipe = __decorate([
39
+ exports.ValidationPipe = ValidationPipe;
40
+ exports.ValidationPipe = ValidationPipe = __decorate([
40
41
  (0, common_1.Injectable)(),
41
42
  __metadata("design:paramtypes", [Object])
42
43
  ], ValidationPipe);
43
- exports.ValidationPipe = ValidationPipe;
@@ -0,0 +1,47 @@
1
+ const assert = require('node:assert/strict');
2
+ const test = require('node:test');
3
+ const { Observable } = require('rxjs');
4
+
5
+ const { AmqpHandler, HttpExceptionCustom } = require('../functions/amqp-handler.function.js');
6
+
7
+ test('param.timeout이 지나면 AMQP Observable 구독을 해제한다', async () => {
8
+ let isUnsubscribed = false;
9
+ const client = {
10
+ send() {
11
+ return new Observable(() => () => {
12
+ isUnsubscribed = true;
13
+ });
14
+ },
15
+ };
16
+
17
+ await assert.rejects(
18
+ AmqpHandler(client, 'test.timeout', {
19
+ payload: {},
20
+ param: {
21
+ traceId: 'trace-id',
22
+ timeout: 5,
23
+ },
24
+ }),
25
+ (error) => {
26
+ assert.equal(error instanceof HttpExceptionCustom, true);
27
+ assert.equal(error.errInfo.type, 'TIMEOUT_ERROR');
28
+ return true;
29
+ },
30
+ );
31
+
32
+ assert.equal(isUnsubscribed, true);
33
+ });
34
+
35
+ test('응답이 먼저 완료되면 기존 AMQP 응답을 반환한다', async () => {
36
+ const client = {
37
+ send() {
38
+ return new Observable((subscriber) => {
39
+ subscriber.next({ isError: false, data: { ok: true } });
40
+ subscriber.complete();
41
+ });
42
+ },
43
+ };
44
+
45
+ const result = await AmqpHandler(client, 'test.success', { payload: {}, param: { traceId: 'trace-id', timeout: 50 } });
46
+ assert.deepEqual(result, { data: { ok: true } });
47
+ });
@@ -0,0 +1,102 @@
1
+ const assert = require('node:assert/strict');
2
+ const os = require('node:os');
3
+ const test = require('node:test');
4
+
5
+ const {
6
+ GracefulServerRMQ,
7
+ } = require('../modules/graceful-shutdown/graceful-shutdown.rmq.js');
8
+
9
+ const CONNECTION_NAME_ENV_KEYS = [
10
+ 'ENV',
11
+ 'NODE_ENV',
12
+ 'RMQ_OWNER',
13
+ 'USER',
14
+ 'USERNAME',
15
+ ];
16
+
17
+ function getClientProperties(options) {
18
+ const server = new GracefulServerRMQ(options);
19
+ return server.options.socketOptions.connectionOptions.clientProperties;
20
+ }
21
+
22
+ function runWithEnvironment(environment, callback) {
23
+ const originalEnvironment = Object.fromEntries(
24
+ CONNECTION_NAME_ENV_KEYS.map((key) => [key, process.env[key]]),
25
+ );
26
+ try {
27
+ for (const key of CONNECTION_NAME_ENV_KEYS) {
28
+ delete process.env[key];
29
+ }
30
+ Object.assign(process.env, environment);
31
+ callback();
32
+ } finally {
33
+ for (const key of CONNECTION_NAME_ENV_KEYS) {
34
+ const originalValue = originalEnvironment[key];
35
+ if (originalValue === undefined) {
36
+ delete process.env[key];
37
+ } else {
38
+ process.env[key] = originalValue;
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ test('자동 connection_name에 큐와 실행 주체 정보를 포함한다', () => {
45
+ runWithEnvironment({ ENV: 'release', RMQ_OWNER: 'jun' }, () => {
46
+ const actualClientProperties = getClientProperties({ queue: 'STORE_ITEM_SERVER' });
47
+ const expectedConnectionName = `STORE_ITEM_SERVER/release/jun/${os.hostname()}/pid-${process.pid}`;
48
+ assert.equal(actualClientProperties.connection_name, expectedConnectionName);
49
+ });
50
+ });
51
+
52
+ test('기존 connectionOptions와 clientProperties를 보존한다', () => {
53
+ runWithEnvironment({ NODE_ENV: 'production', USER: 'deploy' }, () => {
54
+ const inputOptions = {
55
+ queue: 'USER_SERVICE',
56
+ socketOptions: {
57
+ noDelay: true,
58
+ connectionOptions: {
59
+ locale: 'ko_KR',
60
+ clientProperties: {
61
+ product: 'croket',
62
+ },
63
+ },
64
+ },
65
+ };
66
+ const server = new GracefulServerRMQ(inputOptions);
67
+ assert.equal(server.options.socketOptions.noDelay, true);
68
+ assert.equal(server.options.socketOptions.connectionOptions.locale, 'ko_KR');
69
+ assert.equal(server.options.socketOptions.connectionOptions.clientProperties.product, 'croket');
70
+ });
71
+ });
72
+
73
+ test('명시적으로 설정한 문자열 connection_name을 보존한다', () => {
74
+ const actualClientProperties = getClientProperties({
75
+ queue: 'USER_SERVICE',
76
+ socketOptions: {
77
+ connectionOptions: {
78
+ clientProperties: {
79
+ connection_name: 'custom-connection-name',
80
+ },
81
+ },
82
+ },
83
+ });
84
+ assert.equal(actualClientProperties.connection_name, 'custom-connection-name');
85
+ });
86
+
87
+ test('문자열이 아닌 connection_name은 자동 생성값으로 대체한다', () => {
88
+ runWithEnvironment({ ENV: 'release', RMQ_OWNER: 'jun' }, () => {
89
+ const actualClientProperties = getClientProperties({
90
+ queue: 'STORE_ITEM_SERVER',
91
+ socketOptions: {
92
+ connectionOptions: {
93
+ clientProperties: {
94
+ connection_name: 123,
95
+ },
96
+ },
97
+ },
98
+ });
99
+ const expectedConnectionName = `STORE_ITEM_SERVER/release/jun/${os.hostname()}/pid-${process.pid}`;
100
+ assert.equal(actualClientProperties.connection_name, expectedConnectionName);
101
+ });
102
+ });