@autofleet/rabbit 3.3.0-beta.10 → 3.3.0-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/.nvmrc CHANGED
@@ -1 +1 @@
1
- v22.9.0
1
+ v20
package/dist/index.d.ts CHANGED
@@ -3,7 +3,8 @@ import { EventEmitter } from 'events';
3
3
  import { AmqpConnectionManager, ChannelWrapper, CreateChannelOpts } from 'amqp-connection-manager';
4
4
  import { ConfirmChannel, ConsumeMessage, Options, Replies } from 'amqplib';
5
5
  import { RedisConfig } from './lib/redis';
6
- import { CallbackFunction, ConsumeMessageOrNull, ConsumeOptions, CustomMessageHeaders, QueuesCache, RedisLockType, ExchangesCache, QueueSetupPromisesDictionary, AssertExchangePromisesDictionary } from './lib/types';
6
+ import { ConnectionPurpose } from './lib/consts';
7
+ import { CallbackFunction, ConsumeMessageOrNull, ConsumeOptions, CustomMessageHeaders, QueuesCache, RedisLockType, ExchangesCache, QueueSetupPromisesDictionary, AssertExchangePromisesDictionary, ConnectionData } from './lib/types';
7
8
  export interface IAfRabbitMq {
8
9
  ack: any;
9
10
  nack: any;
@@ -37,10 +38,12 @@ type newChannelOpts = {
37
38
  name?: string;
38
39
  onClose?: null | ((args: any | null) => void);
39
40
  options?: CreateChannelOpts | undefined;
41
+ connectionPurpose?: ConnectionPurpose;
40
42
  };
41
43
  type assertChannelOpts = {
42
44
  channelName?: string;
43
45
  force?: boolean;
46
+ connectionPurpose?: ConnectionPurpose;
44
47
  };
45
48
  declare class RabbitMq implements IAfRabbitMq {
46
49
  static parseMsg(msg: any): any;
@@ -57,12 +60,14 @@ declare class RabbitMq implements IAfRabbitMq {
57
60
  };
58
61
  DISCONNECT_MSG: string;
59
62
  RECONNECT_MSG: string;
60
- channel: ChannelWrapper | null;
63
+ publishChannel: ChannelWrapper | null;
61
64
  publishChannelSetupPromise: Promise<ChannelWrapper> | null;
62
65
  blockReconnect: boolean | null | undefined;
63
- connection: AmqpConnectionManager | null | undefined;
66
+ connectionsMap: {
67
+ [ConnectionPurpose.Consume]: ConnectionData;
68
+ [ConnectionPurpose.Publish]: ConnectionData;
69
+ };
64
70
  em: EventEmitter;
65
- creatingConnection: boolean;
66
71
  exchanges: ExchangesCache;
67
72
  queues: QueuesCache;
68
73
  queueSetupPromises: QueueSetupPromisesDictionary;
@@ -73,30 +78,15 @@ declare class RabbitMq implements IAfRabbitMq {
73
78
  /** Array of consumers tags used for canceling consumption */
74
79
  consumersTags: Array<[ConfirmChannel, string]>;
75
80
  private consumers;
76
- private doesVHostExist;
77
- private vhost;
78
- oldChannel: ChannelWrapper | null;
79
- oldPublishChannelSetupPromise: Promise<ChannelWrapper> | null;
80
- oldBlockReconnect: boolean | null | undefined;
81
- oldConnection: AmqpConnectionManager | null | undefined;
82
- oldEm: EventEmitter;
83
- oldCreatingConnection: boolean;
84
- oldExchanges: ExchangesCache;
85
- oldQueues: QueuesCache;
86
- oldQueueSetupPromises: QueueSetupPromisesDictionary;
87
- oldAssertExchangePromises: AssertExchangePromisesDictionary;
88
- oldConsumersTags: Array<[ConfirmChannel, string]>;
89
- private oldConsumers;
90
81
  constructor(options?: AfRabbitOptions, redisConfig?: RedisConfig);
91
- private assertVHost;
92
82
  private shouldConsumeMessageByTimestamp;
93
83
  ack: (channel: ConfirmChannel, msg: ConsumeMessageOrNull, shouldUpdateRedisTimestamp?: boolean, releaseLock?: null) => (userMsg: ConsumeMessage) => Promise<any>;
94
84
  nack: (channel: ConfirmChannel, queue: string, options: any, deadQueueOptions: Options.AssertQueue, msg: ConsumeMessageOrNull, releaseLock: any) => (userMsg: ConsumeMessageOrNull, { skipRetry, }?: NackOptions) => Promise<any>;
95
- getConnection(): Promise<AmqpConnectionManager>;
96
- getNewChannel({ name, onClose, options }?: newChannelOpts): Promise<ChannelWrapper>;
97
- assertChannel({ force }?: assertChannelOpts): Promise<ChannelWrapper>;
85
+ getConnection(connectionPurpose: ConnectionPurpose): Promise<AmqpConnectionManager | null | undefined>;
86
+ getNewChannel({ name, onClose, options, connectionPurpose, }: newChannelOpts): Promise<ChannelWrapper>;
87
+ assertChannel({ force, connectionPurpose }: assertChannelOpts): Promise<ChannelWrapper>;
98
88
  assertExchange(exchangeName: string, options?: any): Promise<any>;
99
- getQueueLength(queue: string): Promise<Replies.AssertQueue>;
89
+ getQueueLength(queue: string, connectionPurpose?: ConnectionPurpose): Promise<Replies.AssertQueue>;
100
90
  private deleteQueue;
101
91
  bindQueue(queue: string, exchange: string): Promise<void>;
102
92
  setupQueue(queueName: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
@@ -104,8 +94,6 @@ declare class RabbitMq implements IAfRabbitMq {
104
94
  assertQueue(queueName: string, options?: Options.AssertQueue): Promise<any>;
105
95
  private saveConsumer;
106
96
  consume(queue: string, callback: CallbackFunction, options?: ConsumeOptions): Promise<any>;
107
- consumeNew(queue: string, callback: CallbackFunction, options?: ConsumeOptions): Promise<any>;
108
- consumeOld(queue: string, callback: CallbackFunction, options?: ConsumeOptions): Promise<any>;
109
97
  private lockRedisIfNeeded;
110
98
  private unlockRedisIfNeeded;
111
99
  private consumeFromRabbit;
@@ -114,15 +102,6 @@ declare class RabbitMq implements IAfRabbitMq {
114
102
  sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<boolean | undefined>;
115
103
  isConnected(): Promise<boolean>;
116
104
  gracefulShutdown(signal: string): Promise<void>;
117
- private consumeFromRabbitOld;
118
- getNewChannelOld({ name, onClose, options }?: newChannelOpts): Promise<ChannelWrapper>;
119
- getConnectionOld(): Promise<AmqpConnectionManager>;
120
- private saveConsumerOld;
121
- assertQueueOld(queueName: string, options?: Options.AssertQueue): Promise<any>;
122
- setupQueueOld(queueName: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
123
- assertChannelOld({ force }?: assertChannelOpts): Promise<ChannelWrapper>;
124
- private deleteQueueOld;
125
- assertExchangeOld(exchangeName: string, options?: any): Promise<any>;
126
105
  }
127
106
  export default RabbitMq;
128
107
  export { sendCeleryTaskViaHttp, } from './lib/celery';