@autofleet/rabbit 2.1.11 → 2.1.12-beta2
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/.env +0 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -35
- package/dump.rdb +0 -0
- package/package.json +1 -1
- package/src/index.ts +7 -14
package/.env
ADDED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -52,10 +52,10 @@ declare class RabbitMq implements IAfRabbitMq {
|
|
|
52
52
|
assertExchange(exchangeName: string, options?: any): Promise<any>;
|
|
53
53
|
getQueueLength(queue: string): Promise<import("amqplib").Replies.AssertQueue>;
|
|
54
54
|
bindQueue(queue: string, exchange: string): Promise<void>;
|
|
55
|
-
assertQueue(queue: string, options?: Options.AssertQueue): Promise<
|
|
55
|
+
assertQueue(queue: string, options?: Options.AssertQueue): Promise<import("amqplib").Replies.AssertQueue>;
|
|
56
56
|
consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
|
|
57
57
|
consumeFromExchange(queue: string, exchange: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
|
|
58
|
-
publish(exchange: string, content: any, customHeaders?: any): Promise<
|
|
58
|
+
publish(exchange: string, content: any, customHeaders?: any): Promise<void>;
|
|
59
59
|
sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<boolean>;
|
|
60
60
|
isConnected(): Promise<boolean>;
|
|
61
61
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,9 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment,@typescript-eslint/ban-types,@typescript-eslint/no-unused-vars,consistent-return,no-async-promise-executor,no-param-reassign,no-empty */
|
|
35
|
-
// eslint-disable-next-line max-classes-per-file
|
|
36
|
-
const bluebird = __importStar(require("bluebird"));
|
|
37
15
|
const moment_1 = __importDefault(require("moment"));
|
|
38
16
|
const amqp_connection_manager_1 = require("amqp-connection-manager");
|
|
39
17
|
const events_1 = require("events");
|
|
@@ -122,13 +100,13 @@ class RabbitMq {
|
|
|
122
100
|
getConnection() {
|
|
123
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
102
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
if (this.connection !== null) {
|
|
104
|
+
return resolve(this.connection);
|
|
105
|
+
}
|
|
125
106
|
if (this.creatingConnection) {
|
|
126
107
|
this.em.once(connectionCreatedConst, resolve);
|
|
127
108
|
return;
|
|
128
109
|
}
|
|
129
|
-
if (this.connection !== null) {
|
|
130
|
-
return resolve(this.connection);
|
|
131
|
-
}
|
|
132
110
|
this.creatingConnection = true;
|
|
133
111
|
const username = process.env.RABBITMQ_USERNAME || 'guest';
|
|
134
112
|
const password = process.env.RABBITMQ_PASSWORD || 'guest';
|
|
@@ -208,7 +186,7 @@ class RabbitMq {
|
|
|
208
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
187
|
RabbitMq.validateName('queue', queue);
|
|
210
188
|
const channel = yield this.assertChannel();
|
|
211
|
-
return channel.
|
|
189
|
+
return channel.assertQueue(queue, options);
|
|
212
190
|
});
|
|
213
191
|
}
|
|
214
192
|
consume(queue, callback, options) {
|
|
@@ -273,15 +251,7 @@ class RabbitMq {
|
|
|
273
251
|
RabbitMq.validateName('exchange', exchange);
|
|
274
252
|
const channel = yield this.assertChannel();
|
|
275
253
|
yield this.assertExchange(exchange);
|
|
276
|
-
|
|
277
|
-
try {
|
|
278
|
-
yield channel.publish(exchange, '', Buffer.from(JSON.stringify(content)), RabbitMq.getPublishOptions(customHeaders));
|
|
279
|
-
return resolve();
|
|
280
|
-
}
|
|
281
|
-
catch (e) {
|
|
282
|
-
reject(e);
|
|
283
|
-
}
|
|
284
|
-
})).timeout(this.PUBLISH_TIMEOUT, `${this.PUBLISH_ERROR_MSG}${exchange}`);
|
|
254
|
+
yield channel.publish(exchange, '', Buffer.from(JSON.stringify(content)), RabbitMq.getPublishOptions(customHeaders));
|
|
285
255
|
});
|
|
286
256
|
}
|
|
287
257
|
sendToQueue(queue, content, options, customHeaders) {
|
package/dump.rdb
ADDED
|
Binary file
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -158,13 +158,13 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
158
158
|
|
|
159
159
|
async getConnection() {
|
|
160
160
|
return new Promise<AmqpConnectionManager>(async (resolve) => {
|
|
161
|
+
if (this.connection !== null) {
|
|
162
|
+
return resolve(this.connection);
|
|
163
|
+
}
|
|
161
164
|
if (this.creatingConnection) {
|
|
162
165
|
this.em.once(connectionCreatedConst, resolve);
|
|
163
166
|
return;
|
|
164
167
|
}
|
|
165
|
-
if (this.connection !== null) {
|
|
166
|
-
return resolve(this.connection);
|
|
167
|
-
}
|
|
168
168
|
this.creatingConnection = true;
|
|
169
169
|
const username: string = process.env.RABBITMQ_USERNAME || 'guest';
|
|
170
170
|
const password: string = process.env.RABBITMQ_PASSWORD || 'guest';
|
|
@@ -237,7 +237,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
237
237
|
async assertQueue(queue: string, options?: Options.AssertQueue) {
|
|
238
238
|
RabbitMq.validateName('queue', queue);
|
|
239
239
|
const channel: ChannelWrapper = await this.assertChannel();
|
|
240
|
-
return channel.
|
|
240
|
+
return channel.assertQueue(queue, options);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
async consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {
|
|
@@ -309,16 +309,9 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
309
309
|
RabbitMq.validateName('exchange', exchange);
|
|
310
310
|
const channel: ChannelWrapper = await this.assertChannel();
|
|
311
311
|
await this.assertExchange(exchange);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
Buffer.from(JSON.stringify(content)),
|
|
316
|
-
RabbitMq.getPublishOptions(customHeaders));
|
|
317
|
-
return resolve();
|
|
318
|
-
} catch (e) {
|
|
319
|
-
reject(e);
|
|
320
|
-
}
|
|
321
|
-
}).timeout(this.PUBLISH_TIMEOUT, `${this.PUBLISH_ERROR_MSG}${exchange}`);
|
|
312
|
+
await channel.publish(exchange, '',
|
|
313
|
+
Buffer.from(JSON.stringify(content)),
|
|
314
|
+
RabbitMq.getPublishOptions(customHeaders));
|
|
322
315
|
}
|
|
323
316
|
|
|
324
317
|
async sendToQueue(queue: string, content: any, options?: any, customHeaders?: any) {
|