@autofleet/rabbit 3.2.22-beta.4 → 3.2.22-beta.5

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.js CHANGED
@@ -145,6 +145,7 @@ class RabbitMq {
145
145
  async getConnection(connectionPurpose) {
146
146
  return new Promise(async (resolve, reject) => {
147
147
  const { connection, creatingConnection } = this.connectionsMap[connectionPurpose];
148
+ debug('rabbit: start getting new connection', { connection, creatingConnection, connectionPurpose });
148
149
  if (this.blockReconnect) {
149
150
  debug('rabbit: block reconnect');
150
151
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -212,7 +213,7 @@ class RabbitMq {
212
213
  }
213
214
  });
214
215
  newConnection.once('connect', async () => {
215
- debug('rabbit: connection established');
216
+ debug('rabbit: connection established', { connectionPurpose, connection: this.connectionsMap[connectionPurpose] });
216
217
  this.connectionsMap[connectionPurpose].creatingConnection = false;
217
218
  this.em.emit(consts_1.CONNECTION_CREATED_CONST, newConnection);
218
219
  isResolved = true;
@@ -248,6 +249,7 @@ class RabbitMq {
248
249
  }
249
250
  }
250
251
  async assertChannel({ force = false, connectionPurpose = types_1.ConnectionPurpose.Consume }) {
252
+ debug('rabbit: start assert channel', { connectionPurpose, publishPromise: this.publishChannelSetupPromise, channel: this.channel });
251
253
  if (!this.publishChannelSetupPromise) {
252
254
  this.publishChannelSetupPromise = new Promise(async (resolve, reject) => {
253
255
  if (this.channel && !force) {
@@ -255,6 +257,7 @@ class RabbitMq {
255
257
  }
256
258
  try {
257
259
  const channel = await this.getNewChannel({ connectionPurpose });
260
+ debug('rabbit: new channel got', { connectionPurpose, channel: this.channel });
258
261
  channel.on('error', (err) => {
259
262
  logger_1.default.error('rabbit: channel error', { err });
260
263
  });
@@ -302,6 +305,7 @@ class RabbitMq {
302
305
  }
303
306
  async setupQueue(queueName, connectionPurpose, options) {
304
307
  let queue;
308
+ debug('rabbit: start setup queue', { queueName, connectionPurpose });
305
309
  try {
306
310
  const channel = await this.assertChannel({ connectionPurpose });
307
311
  debug('assertQueue->channel.addSetup', { queueName });
@@ -324,10 +328,12 @@ class RabbitMq {
324
328
  throw e;
325
329
  }
326
330
  }
331
+ debug('rabbit: done setup queue', { queueName, connectionPurpose });
327
332
  this.queues[queueName] = queueName;
328
333
  return queue;
329
334
  }
330
335
  async assertQueue(queueName, connectionPurpose, options) {
336
+ debug('rabbit: start assert queue', { connectionPurpose, queueName });
331
337
  RabbitMq.validateName('queue', queueName);
332
338
  if (this.queues[queueName]) {
333
339
  delete this.queueSetupPromises[queueName];
@@ -337,6 +343,7 @@ class RabbitMq {
337
343
  return this.queueSetupPromises[queueName];
338
344
  }
339
345
  this.queueSetupPromises[queueName] = this.setupQueue(queueName, connectionPurpose, options);
346
+ debug('rabbit: done assert queue', { connectionPurpose, queueName });
340
347
  return this.queueSetupPromises[queueName];
341
348
  }
342
349
  saveConsumer(queue, callback, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.2.22-beta.4",
3
+ "version": "3.2.22-beta.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -279,6 +279,7 @@ class RabbitMq implements IAfRabbitMq {
279
279
  async getConnection(connectionPurpose: ConnectionPurpose) {
280
280
  return new Promise<AmqpConnectionManager | undefined | null>(async (resolve, reject) => {
281
281
  const { connection, creatingConnection } = this.connectionsMap[connectionPurpose];
282
+ debug('rabbit: start getting new connection', { connection, creatingConnection, connectionPurpose });
282
283
  if (this.blockReconnect) {
283
284
  debug('rabbit: block reconnect');
284
285
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -353,7 +354,7 @@ class RabbitMq implements IAfRabbitMq {
353
354
  }
354
355
  });
355
356
  newConnection.once('connect', async () => {
356
- debug('rabbit: connection established');
357
+ debug('rabbit: connection established', { connectionPurpose, connection: this.connectionsMap[connectionPurpose] });
357
358
  this.connectionsMap[connectionPurpose].creatingConnection = false;
358
359
  this.em.emit(CONNECTION_CREATED_CONST, newConnection);
359
360
  isResolved = true;
@@ -391,6 +392,7 @@ class RabbitMq implements IAfRabbitMq {
391
392
  }
392
393
 
393
394
  async assertChannel({ force = false, connectionPurpose = ConnectionPurpose.Consume }: assertChannelOpts): Promise<ChannelWrapper> {
395
+ debug('rabbit: start assert channel', { connectionPurpose, publishPromise: this.publishChannelSetupPromise, channel: this.channel });
394
396
  if (!this.publishChannelSetupPromise) {
395
397
  this.publishChannelSetupPromise = new Promise<ChannelWrapper>(async (resolve, reject) => {
396
398
  if (this.channel && !force) {
@@ -399,6 +401,7 @@ class RabbitMq implements IAfRabbitMq {
399
401
 
400
402
  try {
401
403
  const channel = await this.getNewChannel({ connectionPurpose });
404
+ debug('rabbit: new channel got', { connectionPurpose, channel: this.channel });
402
405
  channel.on('error', (err) => {
403
406
  logger.error('rabbit: channel error', { err });
404
407
  });
@@ -450,6 +453,7 @@ class RabbitMq implements IAfRabbitMq {
450
453
 
451
454
  async setupQueue(queueName: string, connectionPurpose: ConnectionPurpose, options?: Options.AssertQueue): Promise<Replies.AssertQueue> {
452
455
  let queue: Replies.AssertQueue;
456
+ debug('rabbit: start setup queue', { queueName, connectionPurpose });
453
457
  try {
454
458
  const channel: ChannelWrapper = await this.assertChannel({ connectionPurpose });
455
459
  debug('assertQueue->channel.addSetup', { queueName });
@@ -471,12 +475,13 @@ class RabbitMq implements IAfRabbitMq {
471
475
  throw e;
472
476
  }
473
477
  }
474
-
478
+ debug('rabbit: done setup queue', { queueName, connectionPurpose });
475
479
  this.queues[queueName] = queueName;
476
480
  return queue;
477
481
  }
478
482
 
479
483
  async assertQueue(queueName: string, connectionPurpose: ConnectionPurpose, options?: Options.AssertQueue) {
484
+ debug('rabbit: start assert queue', { connectionPurpose, queueName });
480
485
  RabbitMq.validateName('queue', queueName);
481
486
  if (this.queues[queueName]) {
482
487
  delete this.queueSetupPromises[queueName];
@@ -488,6 +493,7 @@ class RabbitMq implements IAfRabbitMq {
488
493
  }
489
494
 
490
495
  this.queueSetupPromises[queueName] = this.setupQueue(queueName, connectionPurpose, options);
496
+ debug('rabbit: done assert queue', { connectionPurpose, queueName });
491
497
  return this.queueSetupPromises[queueName];
492
498
  }
493
499