@autofleet/rabbit 3.3.0-beta.3 → 3.3.0
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 +1 -1
- package/dist/index.d.ts +35 -13
- package/dist/index.js +485 -119
- package/dist/lib/consts.d.ts +2 -4
- package/dist/lib/consts.js +3 -6
- package/dist/lib/types.d.ts +1 -8
- package/package.json +1 -1
- package/src/index.ts +584 -153
- package/src/lib/consts.ts +2 -5
- package/src/lib/types.ts +2 -9
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v22.9.0
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ 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 {
|
|
7
|
-
import { CallbackFunction, ConsumeMessageOrNull, ConsumeOptions, CustomMessageHeaders, QueuesCache, RedisLockType, ExchangesCache, QueueSetupPromisesDictionary, AssertExchangePromisesDictionary, ConnectionData } from './lib/types';
|
|
6
|
+
import { CallbackFunction, ConsumeMessageOrNull, ConsumeOptions, CustomMessageHeaders, QueuesCache, RedisLockType, ExchangesCache, QueueSetupPromisesDictionary, AssertExchangePromisesDictionary } from './lib/types';
|
|
8
7
|
export interface IAfRabbitMq {
|
|
9
8
|
ack: any;
|
|
10
9
|
nack: any;
|
|
@@ -38,12 +37,10 @@ type newChannelOpts = {
|
|
|
38
37
|
name?: string;
|
|
39
38
|
onClose?: null | ((args: any | null) => void);
|
|
40
39
|
options?: CreateChannelOpts | undefined;
|
|
41
|
-
connectionPurpose?: ConnectionPurpose;
|
|
42
40
|
};
|
|
43
41
|
type assertChannelOpts = {
|
|
44
42
|
channelName?: string;
|
|
45
43
|
force?: boolean;
|
|
46
|
-
connectionPurpose?: ConnectionPurpose;
|
|
47
44
|
};
|
|
48
45
|
declare class RabbitMq implements IAfRabbitMq {
|
|
49
46
|
static parseMsg(msg: any): any;
|
|
@@ -60,13 +57,12 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
60
57
|
};
|
|
61
58
|
DISCONNECT_MSG: string;
|
|
62
59
|
RECONNECT_MSG: string;
|
|
63
|
-
|
|
60
|
+
channel: ChannelWrapper | null;
|
|
64
61
|
publishChannelSetupPromise: Promise<ChannelWrapper> | null;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
[ConnectionPurpose.Publish]: ConnectionData;
|
|
68
|
-
};
|
|
62
|
+
blockReconnect: boolean | null | undefined;
|
|
63
|
+
connection: AmqpConnectionManager | null | undefined;
|
|
69
64
|
em: EventEmitter;
|
|
65
|
+
creatingConnection: boolean;
|
|
70
66
|
exchanges: ExchangesCache;
|
|
71
67
|
queues: QueuesCache;
|
|
72
68
|
queueSetupPromises: QueueSetupPromisesDictionary;
|
|
@@ -77,15 +73,30 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
77
73
|
/** Array of consumers tags used for canceling consumption */
|
|
78
74
|
consumersTags: Array<[ConfirmChannel, string]>;
|
|
79
75
|
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;
|
|
80
90
|
constructor(options?: AfRabbitOptions, redisConfig?: RedisConfig);
|
|
91
|
+
private assertVHost;
|
|
81
92
|
private shouldConsumeMessageByTimestamp;
|
|
82
93
|
ack: (channel: ConfirmChannel, msg: ConsumeMessageOrNull, shouldUpdateRedisTimestamp?: boolean, releaseLock?: null) => (userMsg: ConsumeMessage) => Promise<any>;
|
|
83
94
|
nack: (channel: ConfirmChannel, queue: string, options: any, deadQueueOptions: Options.AssertQueue, msg: ConsumeMessageOrNull, releaseLock: any) => (userMsg: ConsumeMessageOrNull, { skipRetry, }?: NackOptions) => Promise<any>;
|
|
84
|
-
getConnection(
|
|
85
|
-
getNewChannel({ name, onClose, options
|
|
86
|
-
assertChannel({ force
|
|
95
|
+
getConnection(): Promise<AmqpConnectionManager>;
|
|
96
|
+
getNewChannel({ name, onClose, options }?: newChannelOpts): Promise<ChannelWrapper>;
|
|
97
|
+
assertChannel({ force }?: assertChannelOpts): Promise<ChannelWrapper>;
|
|
87
98
|
assertExchange(exchangeName: string, options?: any): Promise<any>;
|
|
88
|
-
getQueueLength(queue: string
|
|
99
|
+
getQueueLength(queue: string): Promise<Replies.AssertQueue>;
|
|
89
100
|
private deleteQueue;
|
|
90
101
|
bindQueue(queue: string, exchange: string): Promise<void>;
|
|
91
102
|
setupQueue(queueName: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
|
|
@@ -93,6 +104,8 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
93
104
|
assertQueue(queueName: string, options?: Options.AssertQueue): Promise<any>;
|
|
94
105
|
private saveConsumer;
|
|
95
106
|
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>;
|
|
96
109
|
private lockRedisIfNeeded;
|
|
97
110
|
private unlockRedisIfNeeded;
|
|
98
111
|
private consumeFromRabbit;
|
|
@@ -101,6 +114,15 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
101
114
|
sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<boolean | undefined>;
|
|
102
115
|
isConnected(): Promise<boolean>;
|
|
103
116
|
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>;
|
|
104
126
|
}
|
|
105
127
|
export default RabbitMq;
|
|
106
128
|
export { sendCeleryTaskViaHttp, } from './lib/celery';
|