@autofleet/rabbit 3.2.22-beta.0 → 3.2.22-beta.2

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 CHANGED
@@ -37,7 +37,7 @@ type newChannelOpts = {
37
37
  name?: string;
38
38
  onClose?: null | ((args: any | null) => void);
39
39
  options?: CreateChannelOpts | undefined;
40
- connectionPurpose: ConnectionPurpose;
40
+ connectionPurpose?: ConnectionPurpose;
41
41
  };
42
42
  type assertChannelOpts = {
43
43
  channelName?: string;
package/dist/index.js CHANGED
@@ -182,10 +182,6 @@ class RabbitMq {
182
182
  const newConnection = await (0, amqp_connection_manager_1.connect)(defaultUrls, {
183
183
  findServers,
184
184
  });
185
- if (!newConnection) {
186
- logger_1.default.error('rabbit: couldnt create a connection');
187
- return resolve(connection);
188
- }
189
185
  this.connectionsMap[connectionPurpose].connection = newConnection;
190
186
  newConnection.on('error', (err) => {
191
187
  logger_1.default.error('rabbit: connection error', { err });
@@ -272,7 +268,7 @@ class RabbitMq {
272
268
  }
273
269
  return this.publishChannelSetupPromise;
274
270
  }
275
- async assertExchange(exchangeName, options) {
271
+ async assertExchange(exchangeName, options = { connectionPurpose: types_1.ConnectionPurpose.Consume }) {
276
272
  const channel = await this.assertChannel({ connectionPurpose: options.connectionPurpose });
277
273
  if (this.exchanges[exchangeName]) {
278
274
  return this.exchanges[exchangeName];
@@ -463,7 +459,7 @@ class RabbitMq {
463
459
  RabbitMq.validateName('queue', queue);
464
460
  const { limit, deadMessageTtl } = optionsWithDefaults;
465
461
  await this.saveConsumer(queue, callback, options);
466
- const channel = await this.getNewChannel({ name: `consume - exchange - ${exchange} -queue - ${queue}`, connectionPurpose: types_1.ConnectionPurpose.Consume });
462
+ const channel = await this.getNewChannel({ name: `consume - exchange - ${exchange} -queue - ${queue}` });
467
463
  return channel.addSetup(async (c) => {
468
464
  const assertExchange = await (0, utils_1.assertExchangeFanout)(c, exchange);
469
465
  await c.assertQueue(queue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.2.22-beta.0",
3
+ "version": "3.2.22-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -83,7 +83,7 @@ type newChannelOpts = {
83
83
  name?: string;
84
84
  onClose?: null | ((args: any | null) => void);
85
85
  options?: CreateChannelOpts | undefined;
86
- connectionPurpose: ConnectionPurpose,
86
+ connectionPurpose?: ConnectionPurpose,
87
87
  };
88
88
 
89
89
  type assertChannelOpts = {
@@ -321,11 +321,6 @@ class RabbitMq implements IAfRabbitMq {
321
321
  findServers,
322
322
  });
323
323
 
324
- if (!newConnection) {
325
- logger.error('rabbit: couldnt create a connection');
326
- return resolve(connection);
327
- }
328
-
329
324
  this.connectionsMap[connectionPurpose].connection = newConnection;
330
325
 
331
326
  newConnection.on('error', (err) => {
@@ -417,7 +412,7 @@ class RabbitMq implements IAfRabbitMq {
417
412
  return this.publishChannelSetupPromise;
418
413
  }
419
414
 
420
- async assertExchange(exchangeName: string, options?: any) {
415
+ async assertExchange(exchangeName: string, options: any = { connectionPurpose: ConnectionPurpose.Consume }) {
421
416
  const channel: ChannelWrapper = await this.assertChannel({ connectionPurpose: options.connectionPurpose });
422
417
  if (this.exchanges[exchangeName]) {
423
418
  return this.exchanges[exchangeName];
@@ -638,7 +633,7 @@ class RabbitMq implements IAfRabbitMq {
638
633
  RabbitMq.validateName('queue', queue);
639
634
  const { limit, deadMessageTtl } = optionsWithDefaults;
640
635
  await this.saveConsumer(queue, callback, options);
641
- const channel: ChannelWrapper = await this.getNewChannel({ name: `consume - exchange - ${exchange} -queue - ${queue}`, connectionPurpose: ConnectionPurpose.Consume });
636
+ const channel: ChannelWrapper = await this.getNewChannel({ name: `consume - exchange - ${exchange} -queue - ${queue}` });
642
637
 
643
638
  return channel.addSetup(async (c: ConfirmChannel) => {
644
639
  const assertExchange = await assertExchangeFanout(c, exchange);