@aldb2b/common 1.0.2037 → 1.0.2038

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aldb2b/common",
3
- "version": "1.0.2037",
3
+ "version": "1.0.2038",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
File without changes
@@ -1 +0,0 @@
1
- //# sourceMappingURL=health.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../../../src/utils/rmq/health/health.controller.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { Provider } from '@nestjs/common';
2
- export declare const RobustRmqStrategyProvider: Provider;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RobustRmqStrategyProvider = void 0;
4
- const custom_retry_rmq_strategy_1 = require("../strategies/custom-retry-rmq.strategy");
5
- exports.RobustRmqStrategyProvider = {
6
- provide: 'ROBUST_RMQ_STRATEGY',
7
- useFactory: (queue) => {
8
- return new custom_retry_rmq_strategy_1.CustomRetryRmqStrategy({
9
- queue,
10
- noAck: false,
11
- urls: [process.env.RABBITMQ_URI],
12
- queueOptions: {
13
- durable: true
14
- },
15
- socketOptions: {
16
- heartbeat: 30,
17
- timeout: 10000
18
- },
19
- maxConnectionAttempts: 5,
20
- });
21
- },
22
- };
23
- //# sourceMappingURL=retry-rmq-strategy.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry-rmq-strategy.provider.js","sourceRoot":"","sources":["../../../../src/utils/rmq/providers/retry-rmq-strategy.provider.ts"],"names":[],"mappings":";;;AAEA,uFAA+E;AAElE,QAAA,yBAAyB,GAAa;IAC/C,OAAO,EAAE,qBAAqB;IAC9B,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE;QAC1B,OAAO,IAAI,kDAAsB,CAAC;YAC9B,KAAK;YACL,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;YAChC,YAAY,EAAE;gBACV,OAAO,EAAE,IAAI;aAChB;YACD,aAAa,EAAE;gBACX,SAAS,EAAE,EAAE;gBACb,OAAO,EAAE,KAAK;aACjB;YACD,qBAAqB,EAAE,CAAC;SAC3B,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"}
@@ -1,9 +0,0 @@
1
- import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
2
- export declare class ConnectionMonitorService implements OnApplicationBootstrap, OnApplicationShutdown {
3
- private readonly logger;
4
- private monitoringInterval;
5
- onApplicationBootstrap(): void;
6
- onApplicationShutdown(): void;
7
- private startMonitoring;
8
- private stopMonitoring;
9
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var ConnectionMonitorService_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ConnectionMonitorService = void 0;
11
- const common_1 = require("@nestjs/common");
12
- const common_2 = require("@nestjs/common");
13
- let ConnectionMonitorService = ConnectionMonitorService_1 = class ConnectionMonitorService {
14
- constructor() {
15
- this.logger = new common_2.Logger(ConnectionMonitorService_1.name);
16
- }
17
- onApplicationBootstrap() {
18
- this.startMonitoring();
19
- }
20
- onApplicationShutdown() {
21
- this.stopMonitoring();
22
- }
23
- startMonitoring() {
24
- this.monitoringInterval = setInterval(() => {
25
- this.logger.debug('RabbitMQ connection monitor - active');
26
- }, 30000);
27
- }
28
- stopMonitoring() {
29
- if (this.monitoringInterval) {
30
- clearInterval(this.monitoringInterval);
31
- this.logger.log('Stopped connection monitoring');
32
- }
33
- }
34
- };
35
- exports.ConnectionMonitorService = ConnectionMonitorService;
36
- exports.ConnectionMonitorService = ConnectionMonitorService = ConnectionMonitorService_1 = __decorate([
37
- (0, common_1.Injectable)()
38
- ], ConnectionMonitorService);
39
- //# sourceMappingURL=connection-monitor.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-monitor.service.js","sourceRoot":"","sources":["../../../../src/utils/rmq/services/connection-monitor.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA2F;AAC3F,2CAAwC;AAGjC,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAA9B;QACc,WAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAuBxE,CAAC;IApBG,sBAAsB;QAClB,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAED,qBAAqB;QACjB,IAAI,CAAC,cAAc,EAAE,CAAC;IAC1B,CAAC;IAEO,eAAe;QACnB,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE;YACvC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC9D,CAAC,EAAE,KAAK,CAAC,CAAC;IACd,CAAC;IAEO,cAAc;QAClB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ,CAAA;AAxBY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;GACA,wBAAwB,CAwBpC"}
@@ -1,15 +0,0 @@
1
- import { CustomTransportStrategy, ServerRMQ } from '@nestjs/microservices';
2
- import { Channel } from 'amqplib';
3
- export declare class CustomRetryRmqStrategy extends ServerRMQ implements CustomTransportStrategy {
4
- protected readonly options: any;
5
- private readonly localLogger;
6
- private reconnectAttempts;
7
- private readonly maxReconnectAttempts;
8
- private readonly baseReconnectDelay;
9
- private isExplicitlyClosed;
10
- constructor(options: any);
11
- setupChannel(channel: Channel, callback: Function): Promise<void>;
12
- private handleReconnection;
13
- close(): Promise<void>;
14
- isConnected(): boolean;
15
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomRetryRmqStrategy = void 0;
4
- const microservices_1 = require("@nestjs/microservices");
5
- const common_1 = require("@nestjs/common");
6
- class CustomRetryRmqStrategy extends microservices_1.ServerRMQ {
7
- constructor(options) {
8
- super({
9
- ...options,
10
- socketOptions: {
11
- heartbeat: 30,
12
- timeout: 10000,
13
- ...options.socketOptions,
14
- },
15
- });
16
- this.options = options;
17
- this.localLogger = new common_1.Logger(CustomRetryRmqStrategy.name);
18
- this.reconnectAttempts = 0;
19
- this.maxReconnectAttempts = 5;
20
- this.baseReconnectDelay = 2000;
21
- this.isExplicitlyClosed = false;
22
- }
23
- async setupChannel(channel, callback) {
24
- channel.on('error', (error) => {
25
- this.localLogger.error(`Channel error: ${error.message}`);
26
- if (!this.isExplicitlyClosed) {
27
- this.handleReconnection();
28
- }
29
- });
30
- channel.on('close', async () => {
31
- if (!this.isExplicitlyClosed) {
32
- this.localLogger.warn('Channel closed unexpectedly');
33
- await this.handleReconnection();
34
- }
35
- });
36
- await super.setupChannel(channel, callback);
37
- }
38
- async handleReconnection() {
39
- if (this.reconnectAttempts >= this.maxReconnectAttempts) {
40
- this.localLogger.error('Maximum reconnection attempts reached');
41
- return;
42
- }
43
- this.reconnectAttempts++;
44
- const delayMs = this.baseReconnectDelay * Math.pow(2, this.reconnectAttempts - 1);
45
- this.localLogger.log(`Attempting reconnect in ${delayMs}ms (attempt ${this.reconnectAttempts})`);
46
- await new Promise(resolve => setTimeout(resolve, delayMs));
47
- try {
48
- await this.close();
49
- this.isExplicitlyClosed = false;
50
- await super.start();
51
- this.reconnectAttempts = 0;
52
- this.localLogger.log('Successfully reconnected to RabbitMQ');
53
- }
54
- catch (error) {
55
- this.localLogger.error(`Reconnection failed: ${error.message}`);
56
- await this.handleReconnection();
57
- }
58
- }
59
- async close() {
60
- this.isExplicitlyClosed = true;
61
- return super.close();
62
- }
63
- isConnected() {
64
- return !this.isExplicitlyClosed && this.reconnectAttempts === 0;
65
- }
66
- }
67
- exports.CustomRetryRmqStrategy = CustomRetryRmqStrategy;
68
- //# sourceMappingURL=custom-retry-rmq.strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-retry-rmq.strategy.js","sourceRoot":"","sources":["../../../../src/utils/rmq/strategies/custom-retry-rmq.strategy.ts"],"names":[],"mappings":";;;AACA,yDAA2E;AAC3E,2CAAwC;AAGxC,MAAa,sBAAuB,SAAQ,yBAAS;IAOjD,YAA+B,OAAY;QACvC,KAAK,CAAC;YACF,GAAG,OAAO;YACV,aAAa,EAAE;gBACX,SAAS,EAAE,EAAE;gBACb,OAAO,EAAE,KAAK;gBACd,GAAG,OAAO,CAAC,aAAa;aAC3B;SACJ,CAAC,CAAC;QARwB,YAAO,GAAP,OAAO,CAAK;QAN1B,gBAAW,GAAG,IAAI,eAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC/D,sBAAiB,GAAG,CAAC,CAAC;QACb,yBAAoB,GAAG,CAAC,CAAC;QACzB,uBAAkB,GAAG,IAAI,CAAC;QACnC,uBAAkB,GAAG,KAAK,CAAC;IAWnC,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,OAAgB,EAAE,QAAkB;QAC1D,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EA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