@autofleet/rabbit 3.2.2-2.beta-0 → 3.2.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 +1 -1
- package/dist/index.d.ts +18 -27
- package/dist/index.js +171 -244
- package/dist/lib/redis.d.ts +1 -1
- package/dist/lib/types.d.ts +8 -20
- package/dist/lib/types.js +1 -7
- package/dist/lib/utils.js +3 -6
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +2 -5
- package/package.json +13 -12
- package/src/index.ts +155 -244
- package/src/lib/types.ts +1 -16
- package/src/logger.ts +1 -1
- package/tsconfig.json +2 -5
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v16
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { AmqpConnectionManager, ChannelWrapper
|
|
3
|
+
import { AmqpConnectionManager, ChannelWrapper } from 'amqp-connection-manager';
|
|
4
4
|
import { ConfirmChannel, ConsumeMessage, Options, Replies } from 'amqplib';
|
|
5
5
|
import { RedisConfig } from './lib/redis';
|
|
6
|
-
import {
|
|
6
|
+
import { TRACING_HEADER, USER_TRACING_HEADER } from './lib/consts';
|
|
7
|
+
import { CallbackFunction, ConsumeMessageOrNull, ConsumeOptions, CustomMessageHeaders, QueuesCache, RedisLockType, ExchangesCache } from './lib/types';
|
|
7
8
|
export interface IAfRabbitMq {
|
|
8
9
|
ack: any;
|
|
9
10
|
nack: any;
|
|
@@ -16,9 +17,6 @@ export interface IAfRabbitMq {
|
|
|
16
17
|
sendToQueue: any;
|
|
17
18
|
redisClient?: any;
|
|
18
19
|
}
|
|
19
|
-
interface NackOptions {
|
|
20
|
-
skipRetry?: boolean;
|
|
21
|
-
}
|
|
22
20
|
export interface AfRabbitOptions {
|
|
23
21
|
disableReconnect?: boolean;
|
|
24
22
|
/**
|
|
@@ -33,16 +31,13 @@ export interface AfRabbitOptions {
|
|
|
33
31
|
dontRetryAssert?: boolean;
|
|
34
32
|
rabbitHost?: string;
|
|
35
33
|
}
|
|
36
|
-
type newChannelOpts = {
|
|
34
|
+
declare type newChannelOpts = {
|
|
37
35
|
name?: string;
|
|
38
36
|
onClose?: null | ((args: any | null) => void);
|
|
39
|
-
options?: CreateChannelOpts | undefined;
|
|
40
|
-
connectionPurpose: ConnectionPurpose;
|
|
41
37
|
};
|
|
42
|
-
type assertChannelOpts = {
|
|
38
|
+
declare type assertChannelOpts = {
|
|
43
39
|
channelName?: string;
|
|
44
40
|
force?: boolean;
|
|
45
|
-
connectionPurpose: ConnectionPurpose;
|
|
46
41
|
};
|
|
47
42
|
declare class RabbitMq implements IAfRabbitMq {
|
|
48
43
|
static parseMsg(msg: any): any;
|
|
@@ -60,16 +55,12 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
60
55
|
DISCONNECT_MSG: string;
|
|
61
56
|
RECONNECT_MSG: string;
|
|
62
57
|
channel: ChannelWrapper | null;
|
|
63
|
-
publishChannelSetupPromise: Promise<ChannelWrapper> | null;
|
|
64
58
|
blockReconnect: boolean | null | undefined;
|
|
65
|
-
|
|
66
|
-
[ConnectionPurpose.Consume]: ConnectionData;
|
|
67
|
-
[ConnectionPurpose.Publish]: ConnectionData;
|
|
68
|
-
};
|
|
59
|
+
connection: AmqpConnectionManager | null | undefined;
|
|
69
60
|
em: EventEmitter;
|
|
61
|
+
creatingConnection: boolean;
|
|
70
62
|
exchanges: ExchangesCache;
|
|
71
63
|
queues: QueuesCache;
|
|
72
|
-
queueSetupPromises: QueueSetupPromisesDictionary;
|
|
73
64
|
options: AfRabbitOptions | undefined;
|
|
74
65
|
redisClient: any;
|
|
75
66
|
redisLock?: RedisLockType;
|
|
@@ -78,26 +69,26 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
78
69
|
private consumers;
|
|
79
70
|
constructor(options?: AfRabbitOptions, redisConfig?: RedisConfig);
|
|
80
71
|
private shouldConsumeMessageByTimestamp;
|
|
81
|
-
ack: (channel:
|
|
82
|
-
nack: (channel:
|
|
83
|
-
getConnection(
|
|
84
|
-
getNewChannel({ name, onClose
|
|
85
|
-
assertChannel({ force
|
|
72
|
+
ack: (channel: ChannelWrapper, msg: ConsumeMessageOrNull, shouldUpdateRedisTimestamp?: boolean, releaseLock?: null) => (userMsg: ConsumeMessage) => Promise<any>;
|
|
73
|
+
nack: (channel: ChannelWrapper, queue: string, options: any, deadQueueOptions: Options.AssertQueue, msg: ConsumeMessageOrNull, releaseLock: any) => (userMsg: ConsumeMessageOrNull, { skipRetry, }?: any) => Promise<any>;
|
|
74
|
+
getConnection(): Promise<AmqpConnectionManager>;
|
|
75
|
+
getNewChannel({ name, onClose }?: newChannelOpts): Promise<ChannelWrapper>;
|
|
76
|
+
assertChannel({ force }?: assertChannelOpts): Promise<ChannelWrapper>;
|
|
86
77
|
assertExchange(exchangeName: string, options?: any): Promise<any>;
|
|
87
|
-
getQueueLength(queue: string
|
|
78
|
+
getQueueLength(queue: string): Promise<Replies.AssertQueue>;
|
|
88
79
|
private deleteQueue;
|
|
89
|
-
bindQueue(queue: string, exchange: string
|
|
90
|
-
|
|
91
|
-
assertQueue(queueName: string, connectionPurpose: ConnectionPurpose, options?: Options.AssertQueue): Promise<any>;
|
|
80
|
+
bindQueue(queue: string, exchange: string): Promise<void>;
|
|
81
|
+
assertQueue(queueName: string, options?: Options.AssertQueue): Promise<any>;
|
|
92
82
|
private saveConsumer;
|
|
83
|
+
private loadConsumers;
|
|
93
84
|
consume(queue: string, callback: CallbackFunction, options?: ConsumeOptions): Promise<any>;
|
|
94
85
|
private lockRedisIfNeeded;
|
|
95
86
|
private unlockRedisIfNeeded;
|
|
96
87
|
private consumeFromRabbit;
|
|
97
88
|
consumeFromExchange(queue: string, exchange: string, callback: CallbackFunction, options?: ConsumeOptions): Promise<any>;
|
|
98
89
|
publish(exchange: string, content: any, customHeaders?: any): Promise<boolean>;
|
|
99
|
-
sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<boolean | undefined>;
|
|
100
|
-
isConnected(
|
|
90
|
+
sendToQueue(queue: string, content: any, options?: any, customHeaders?: any, isBlocking?: boolean): Promise<boolean | undefined>;
|
|
91
|
+
isConnected(): Promise<boolean>;
|
|
101
92
|
gracefulShutdown(signal: string): Promise<void>;
|
|
102
93
|
}
|
|
103
94
|
export default RabbitMq;
|