@autofleet/rabbit 2.2.8-add-context-1 → 2.2.9-beta
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/dist/index.d.ts +1 -1
- package/dist/index.js +5 -6
- package/package.json +1 -1
- package/src/index.ts +5 -6
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface ConsumeOptions {
|
|
|
35
35
|
}
|
|
36
36
|
declare type CallbackFunction = (msg: ConsumeMessage, ack: Function, nack: Function) => Promise<any>;
|
|
37
37
|
export interface AfRabbitOptions {
|
|
38
|
-
|
|
38
|
+
disableReconnect: boolean;
|
|
39
39
|
}
|
|
40
40
|
declare class RabbitMq implements IAfRabbitMq {
|
|
41
41
|
static parseMsg(msg: any): any;
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
18
18
|
const redis_lock_1 = __importDefault(require("redis-lock"));
|
|
19
19
|
const amqp_connection_manager_1 = require("amqp-connection-manager");
|
|
20
20
|
const events_1 = require("events");
|
|
21
|
-
const outbreak_1 = require("@autofleet/outbreak");
|
|
22
21
|
// import { newTrace, traceTypes } from '@autofleet/outbreak';
|
|
23
22
|
const util_1 = require("util");
|
|
24
23
|
const logger_1 = __importDefault(require("./logger"));
|
|
@@ -137,6 +136,7 @@ class RabbitMq {
|
|
|
137
136
|
return;
|
|
138
137
|
}
|
|
139
138
|
this.creatingConnection = true;
|
|
139
|
+
logger_1.default.info('rabbit: env username', { userName: (process.env.RABBITMQ_USERNAME || 'doesnt exist') });
|
|
140
140
|
const username = process.env.RABBITMQ_USERNAME || 'guest';
|
|
141
141
|
const password = process.env.RABBITMQ_PASSWORD || 'guest';
|
|
142
142
|
const host = process.env.RABBITMQ_SERVICE_HOST || '';
|
|
@@ -146,12 +146,12 @@ class RabbitMq {
|
|
|
146
146
|
var _a;
|
|
147
147
|
this.exchanges = {};
|
|
148
148
|
this.queues = {};
|
|
149
|
-
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.
|
|
150
|
-
logger_1.default.error(`${this.
|
|
151
|
-
this.connection = null;
|
|
149
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.disableReconnect) {
|
|
150
|
+
logger_1.default.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`);
|
|
152
151
|
}
|
|
153
152
|
else {
|
|
154
|
-
logger_1.default.error(`${this.
|
|
153
|
+
logger_1.default.error(`${this.RESCONNECT_MSG}${err && ` - ${err}`}`);
|
|
154
|
+
this.connection = null;
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
this.creatingConnection = false;
|
|
@@ -284,7 +284,6 @@ class RabbitMq {
|
|
|
284
284
|
return this.ack(channel, msg)(msg);
|
|
285
285
|
}
|
|
286
286
|
try {
|
|
287
|
-
outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
288
287
|
yield callback(parsedMessage, this.ack(channel, msg, true), this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }, msg));
|
|
289
288
|
}
|
|
290
289
|
catch (e) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ import RedisLock from 'redis-lock';
|
|
|
5
5
|
import { ConfirmChannel, Options, ConsumeMessage } from 'amqplib';
|
|
6
6
|
import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-manager';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
|
-
import { newTrace, traceTypes } from '@autofleet/outbreak';
|
|
9
8
|
// import { newTrace, traceTypes } from '@autofleet/outbreak';
|
|
10
9
|
import { promisify } from 'util';
|
|
11
10
|
import logger from './logger';
|
|
@@ -50,7 +49,7 @@ interface ConsumeOptions {
|
|
|
50
49
|
type CallbackFunction = (msg: ConsumeMessage, ack: Function, nack: Function) => Promise<any>
|
|
51
50
|
|
|
52
51
|
export interface AfRabbitOptions {
|
|
53
|
-
|
|
52
|
+
disableReconnect: boolean;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
const DEFAULT_DEAD_TTL_TWO_DAYS = 60000 * 60 * 48;
|
|
@@ -216,6 +215,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
216
215
|
return;
|
|
217
216
|
}
|
|
218
217
|
this.creatingConnection = true;
|
|
218
|
+
logger.info('rabbit: env username', { userName: (process.env.RABBITMQ_USERNAME || 'doesnt exist') });
|
|
219
219
|
const username: string = process.env.RABBITMQ_USERNAME || 'guest';
|
|
220
220
|
const password: string = process.env.RABBITMQ_PASSWORD || 'guest';
|
|
221
221
|
const host: string = process.env.RABBITMQ_SERVICE_HOST || '';
|
|
@@ -225,11 +225,11 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
225
225
|
({ err }) => {
|
|
226
226
|
this.exchanges = {};
|
|
227
227
|
this.queues = {};
|
|
228
|
-
if (this.options?.
|
|
228
|
+
if (this.options?.disableReconnect) {
|
|
229
|
+
logger.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`);
|
|
230
|
+
} else {
|
|
229
231
|
logger.error(`${this.RESCONNECT_MSG}${err && ` - ${err}`}`);
|
|
230
232
|
this.connection = null;
|
|
231
|
-
} else {
|
|
232
|
-
logger.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`);
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
this.creatingConnection = false;
|
|
@@ -357,7 +357,6 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
357
357
|
return this.ack(channel, msg)(msg);
|
|
358
358
|
}
|
|
359
359
|
try {
|
|
360
|
-
newTrace(traceTypes.RABBIT);
|
|
361
360
|
await callback(
|
|
362
361
|
parsedMessage,
|
|
363
362
|
this.ack(channel, msg, true),
|