@autofleet/rabbit 3.3.0-beta.11 → 3.3.0-beta.3

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,13 @@ 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
- blockReconnect: boolean | null | undefined;
63
- connection: AmqpConnectionManager | null | undefined;
65
+ connectionsMap: {
66
+ [ConnectionPurpose.Consume]: ConnectionData;
67
+ [ConnectionPurpose.Publish]: ConnectionData;
68
+ };
64
69
  em: EventEmitter;
65
- creatingConnection: boolean;
66
70
  exchanges: ExchangesCache;
67
71
  queues: QueuesCache;
68
72
  queueSetupPromises: QueueSetupPromisesDictionary;
@@ -73,30 +77,15 @@ declare class RabbitMq implements IAfRabbitMq {
73
77
  /** Array of consumers tags used for canceling consumption */
74
78
  consumersTags: Array<[ConfirmChannel, string]>;
75
79
  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
80
  constructor(options?: AfRabbitOptions, redisConfig?: RedisConfig);
91
- private assertVHost;
92
81
  private shouldConsumeMessageByTimestamp;
93
82
  ack: (channel: ConfirmChannel, msg: ConsumeMessageOrNull, shouldUpdateRedisTimestamp?: boolean, releaseLock?: null) => (userMsg: ConsumeMessage) => Promise<any>;
94
83
  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>;
84
+ getConnection(connectionPurpose: ConnectionPurpose): Promise<AmqpConnectionManager | null | undefined>;
85
+ getNewChannel({ name, onClose, options, connectionPurpose, }: newChannelOpts): Promise<ChannelWrapper>;
86
+ assertChannel({ force, connectionPurpose }: assertChannelOpts): Promise<ChannelWrapper>;
98
87
  assertExchange(exchangeName: string, options?: any): Promise<any>;
99
- getQueueLength(queue: string): Promise<Replies.AssertQueue>;
88
+ getQueueLength(queue: string, connectionPurpose?: ConnectionPurpose): Promise<Replies.AssertQueue>;
100
89
  private deleteQueue;
101
90
  bindQueue(queue: string, exchange: string): Promise<void>;
102
91
  setupQueue(queueName: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
@@ -104,8 +93,6 @@ declare class RabbitMq implements IAfRabbitMq {
104
93
  assertQueue(queueName: string, options?: Options.AssertQueue): Promise<any>;
105
94
  private saveConsumer;
106
95
  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
96
  private lockRedisIfNeeded;
110
97
  private unlockRedisIfNeeded;
111
98
  private consumeFromRabbit;
@@ -114,15 +101,6 @@ declare class RabbitMq implements IAfRabbitMq {
114
101
  sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<boolean | undefined>;
115
102
  isConnected(): Promise<boolean>;
116
103
  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
104
  }
127
105
  export default RabbitMq;
128
106
  export { sendCeleryTaskViaHttp, } from './lib/celery';