@autofleet/rabbit 1.5.2 → 1.5.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/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { AmqpConnectionManager, ChannelWrapper } from 'amqp-connection-manager';
3
3
  import { EventEmitter } from 'events';
4
+ import RabbitWrapperInterface from './interfaces/RabbitWrapperInterface';
4
5
  interface ExchangesCache {
5
6
  [key: string]: any;
6
7
  }
7
- declare class RabbitMq {
8
+ declare class RabbitMq implements RabbitWrapperInterface {
8
9
  static parseMsg(msg: any): any;
9
10
  static validateName(type: string, name: string): void;
10
11
  PUBLISH_TIMEOUT: number;
@@ -15,7 +16,12 @@ declare class RabbitMq {
15
16
  em: EventEmitter;
16
17
  creatingConnection: boolean;
17
18
  exchanges: ExchangesCache;
18
- constructor();
19
+ isTestEnv: boolean;
20
+ constructor({ isTestEnv }?: {
21
+ isTestEnv?: boolean | undefined;
22
+ });
23
+ private getConnectFunc;
24
+ private connect;
19
25
  ack: (msg: any) => Promise<void>;
20
26
  nack: (queue: string) => (msg: any, retries: number) => Promise<void>;
21
27
  getConnection(): Promise<AmqpConnectionManager>;
package/dist/index.js CHANGED
@@ -14,14 +14,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  const bluebird = require("bluebird");
15
15
  const amqp_connection_manager_1 = require("amqp-connection-manager");
16
16
  const events_1 = require("events");
17
+ const mockImpl_1 = require("./mockImpl");
17
18
  const rabbitError_1 = require("./rabbitError");
18
19
  const assertExchangeFanout = (c, exchangeName) => c.assertExchange(exchangeName, 'fanout');
19
20
  const connectionCreatedConst = 'connectionCreated';
20
21
  class RabbitMq {
21
- constructor() {
22
+ constructor({ isTestEnv = false } = {}) {
22
23
  this.PUBLISH_TIMEOUT = Number(process.env.RABBITMQ_PUBLISH_TIMEOUT) || 60000;
23
24
  this.PUBLISH_ERROR_MSG = `rabbit: publish timeout(${this.PUBLISH_TIMEOUT}ms) has pass, exchange: `;
24
25
  this.DISCONNECT_MSG = 'rabbit: connection disconnect';
26
+ this.getConnectFunc = () => (this.isTestEnv ? mockImpl_1.connect : amqp_connection_manager_1.connect);
27
+ this.connect = (urls = []) => this.getConnectFunc()(urls);
25
28
  this.ack = (msg) => __awaiter(this, void 0, void 0, function* () {
26
29
  if (this.channel) {
27
30
  yield this.channel.ack(msg);
@@ -46,6 +49,7 @@ class RabbitMq {
46
49
  this.connection = null;
47
50
  this.creatingConnection = false;
48
51
  this.exchanges = {};
52
+ this.isTestEnv = isTestEnv;
49
53
  }
50
54
  static parseMsg(msg) {
51
55
  let { content } = msg;
@@ -73,7 +77,7 @@ class RabbitMq {
73
77
  }
74
78
  this.creatingConnection = true;
75
79
  const host = process.env.RABBITMQ_SERVICE_HOST || '';
76
- const connection = yield amqp_connection_manager_1.connect([`amqp://${host}`]);
80
+ const connection = yield this.connect([`amqp://${host}`]);
77
81
  this.connection = connection;
78
82
  this.connection.on('disconnect', ({ err }) => console.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`));
79
83
  this.creatingConnection = false;
@@ -91,7 +95,7 @@ class RabbitMq {
91
95
  const connection = yield this.getConnection();
92
96
  try {
93
97
  if (this.channel === null) {
94
- this.channel = connection.createChannel({});
98
+ this.channel = yield connection.createChannel({});
95
99
  }
96
100
  resolve(this.channel);
97
101
  }
@@ -0,0 +1,15 @@
1
+ interface RabbitWrapperInterface {
2
+ ack: any;
3
+ nack: any;
4
+ getConnection: any;
5
+ assertChannel: any;
6
+ assertExchange: any;
7
+ getQueueLength: any;
8
+ bindQueue: any;
9
+ assertQueue: any;
10
+ consume: any;
11
+ consumeFromExchange: any;
12
+ publish: any;
13
+ sendToQueue: any;
14
+ }
15
+ export default RabbitWrapperInterface;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ export interface channel {
2
+ assertQueue: any;
3
+ assertExchange: any;
4
+ bindQueue: any;
5
+ publish: any;
6
+ consume: any;
7
+ deleteQueue: any;
8
+ ack: any;
9
+ nack: any;
10
+ prefetch: any;
11
+ on: any;
12
+ once: any;
13
+ close: any;
14
+ addSetup: any;
15
+ checkQueue: any;
16
+ sendToQueue: any;
17
+ }
18
+ export interface connection {
19
+ createChannel: any;
20
+ createConfirmChannel: any;
21
+ on: any;
22
+ once: any;
23
+ close: any;
24
+ }
25
+ export declare const connect: () => any;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.connect = void 0;
13
+ const Bluebird = require("bluebird");
14
+ let exchanges = {};
15
+ let queues = {};
16
+ const setIfUndef = (object, prop, value) => {
17
+ if (!object[prop]) {
18
+ // eslint-disable-next-line no-param-reassign
19
+ object[prop] = value;
20
+ }
21
+ };
22
+ class ChannelImpl {
23
+ constructor() {
24
+ this.assertQueue = (queue, qOptions) => new Bluebird((resolve) => {
25
+ setIfUndef(queues, queue, { messages: [], subscribers: [], options: qOptions });
26
+ return resolve();
27
+ });
28
+ this.assertExchange = (exchange, type, exchOptions = {}) => new Bluebird((resolve) => {
29
+ setIfUndef(exchanges, exchange, { bindings: [], options: exchOptions, type });
30
+ return resolve();
31
+ });
32
+ this.bindQueue = (queue, exchange, key) => new Bluebird((resolve, reject) => {
33
+ if (!exchanges[exchange])
34
+ return reject(`Bind to non-existing exchange ${exchange}`);
35
+ const re = `^${key.replace('.', '\\.').replace('#', '(\\w|\\.)+').replace('*', '\\w+')}$`;
36
+ exchanges[exchange].bindings.push({ regex: new RegExp(re), queueName: queue });
37
+ return resolve();
38
+ });
39
+ this.publish = (exchange, routingKey, content, props) => new Bluebird((resolve, reject) => {
40
+ if (!exchanges[exchange])
41
+ return reject(`Publish to non-existing exchange ${exchange}`);
42
+ const { bindings } = exchanges[exchange];
43
+ const matchingBindings = bindings.filter((b) => b.regex.test(routingKey));
44
+ matchingBindings.forEach((binding) => {
45
+ const subscribers = queues[binding.queueName] ? queues[binding.queueName].subscribers : [];
46
+ subscribers.forEach((sub) => {
47
+ const message = { fields: { routingKey }, properties: props, content };
48
+ sub(message);
49
+ });
50
+ });
51
+ return resolve();
52
+ });
53
+ this.consume = (queue, handler) => {
54
+ queues[queue].subscribers.push(handler);
55
+ };
56
+ this.sendToQueue = (queue, content, routingKey = '', props = {}) => {
57
+ const subscribers = queues[queue] ? queues[queue].subscribers : [];
58
+ subscribers.forEach((sub) => {
59
+ const message = { fields: { routingKey }, properties: props, content };
60
+ sub(message);
61
+ });
62
+ };
63
+ this.deleteQueue = (queue) => {
64
+ setImmediate(() => {
65
+ delete queues[queue];
66
+ });
67
+ };
68
+ this.checkQueue = () => ({ messageCount: 0 });
69
+ this.ack = () => null;
70
+ this.nack = () => null;
71
+ this.prefetch = () => null;
72
+ this.on = () => null;
73
+ this.once = () => null;
74
+ this.close = () => Bluebird.resolve();
75
+ }
76
+ addSetup(funcToRun) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const val = yield funcToRun(this);
79
+ return val;
80
+ });
81
+ }
82
+ }
83
+ const createChannel = () => new Bluebird((resolve) => resolve(new ChannelImpl()));
84
+ exports.connect = () => new Bluebird((resolve) => {
85
+ const connectionImpl = {
86
+ createChannel,
87
+ createConfirmChannel: createChannel,
88
+ on: () => null,
89
+ once: () => null,
90
+ close: () => Bluebird.resolve(),
91
+ };
92
+ return resolve(connectionImpl);
93
+ });
94
+ const resetMock = () => {
95
+ queues = {};
96
+ exchanges = {};
97
+ };
98
+ module.exports = { connect: exports.connect, resetMock };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /* eslint-disable @typescript-eslint/ban-ts-comment,@typescript-eslint/no-unused-vars */
13
+ const index_1 = require("../index");
14
+ jest.setTimeout(120000);
15
+ const rabbit = new index_1.default({ isTestEnv: true });
16
+ describe('RabbitMQ', () => {
17
+ it('check exchange', () => __awaiter(void 0, void 0, void 0, function* () {
18
+ const callback = (msg, ack) => {
19
+ expect(msg.content).toEqual('hey');
20
+ ack(msg);
21
+ };
22
+ const mockFn = jest.fn(callback);
23
+ yield rabbit.consumeFromExchange('test-q2', 'test-e', mockFn);
24
+ yield rabbit.publish('test-e', 'hey');
25
+ expect(mockFn).toBeCalled();
26
+ }));
27
+ it('check queue', () => __awaiter(void 0, void 0, void 0, function* () {
28
+ const callback = (msg, ack) => {
29
+ expect(msg.content).toEqual('hey-q');
30
+ ack(msg);
31
+ };
32
+ const mockFn = jest.fn(callback);
33
+ yield rabbit.consume('test-q-2', mockFn);
34
+ yield rabbit.sendToQueue('test-q-2', 'hey-q');
35
+ expect(mockFn).toBeCalled();
36
+ }));
37
+ it('cant publish to unknown exchange', () => __awaiter(void 0, void 0, void 0, function* () {
38
+ let err;
39
+ try {
40
+ yield rabbit.publish('', 'hey');
41
+ }
42
+ catch (e) {
43
+ err = e;
44
+ }
45
+ expect(err).toBeDefined();
46
+ }));
47
+ it('get queue length', () => __awaiter(void 0, void 0, void 0, function* () {
48
+ const queueName = 'test-queue-length';
49
+ const exchangeName = 'test-e2';
50
+ yield rabbit.assertQueue(queueName);
51
+ yield rabbit.assertExchange(exchangeName);
52
+ yield rabbit.bindQueue(queueName, exchangeName);
53
+ yield rabbit.publish(exchangeName, 'hey');
54
+ let messageCount;
55
+ ({ messageCount } = yield rabbit.getQueueLength(queueName));
56
+ expect(messageCount).toEqual(0);
57
+ yield rabbit.publish(exchangeName, 'hey');
58
+ ({ messageCount } = yield rabbit.getQueueLength(queueName));
59
+ expect(messageCount).toEqual(0);
60
+ yield rabbit.consumeFromExchange(queueName, exchangeName, (msg, ack) => __awaiter(void 0, void 0, void 0, function* () {
61
+ expect(msg.content).toEqual('hey');
62
+ ack(msg);
63
+ }));
64
+ ({ messageCount } = yield rabbit.getQueueLength(queueName));
65
+ expect(messageCount).toEqual(0);
66
+ }));
67
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -2,8 +2,13 @@
2
2
  // eslint-disable-next-line max-classes-per-file
3
3
  import * as bluebird from 'bluebird';
4
4
  import { ConfirmChannel } from 'amqplib';
5
- import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-manager';
5
+ import {
6
+ AmqpConnectionManager, ChannelWrapper,
7
+ connect as connectAmqp,
8
+ } from 'amqp-connection-manager';
6
9
  import { EventEmitter } from 'events';
10
+ import { connect as connectMock } from './mockImpl';
11
+ import RabbitWrapperInterface from './interfaces/RabbitWrapperInterface';
7
12
  import RabbitError from './rabbitError';
8
13
 
9
14
  interface ExchangesCache {
@@ -13,7 +18,7 @@ interface ExchangesCache {
13
18
  const assertExchangeFanout = (c: any, exchangeName: string) => c.assertExchange(exchangeName, 'fanout');
14
19
 
15
20
  const connectionCreatedConst = 'connectionCreated';
16
- class RabbitMq {
21
+ class RabbitMq implements RabbitWrapperInterface {
17
22
  static parseMsg(msg: any) {
18
23
  let { content } = msg;
19
24
  content = content.toString();
@@ -50,14 +55,21 @@ class RabbitMq {
50
55
 
51
56
  exchanges: ExchangesCache;
52
57
 
53
- constructor() {
58
+ isTestEnv: boolean;
59
+
60
+ constructor({ isTestEnv = false } = {}) {
54
61
  this.em = new EventEmitter();
55
62
  this.channel = null;
56
63
  this.connection = null;
57
64
  this.creatingConnection = false;
58
65
  this.exchanges = {};
66
+ this.isTestEnv = isTestEnv;
59
67
  }
60
68
 
69
+ private getConnectFunc = () => (this.isTestEnv ? connectMock : connectAmqp)
70
+
71
+ private connect = (urls:any[] = []) => this.getConnectFunc()(urls);
72
+
61
73
  public ack = async (msg: any) => {
62
74
  if (this.channel) {
63
75
  await this.channel.ack(msg);
@@ -89,7 +101,7 @@ class RabbitMq {
89
101
  }
90
102
  this.creatingConnection = true;
91
103
  const host: string = process.env.RABBITMQ_SERVICE_HOST || '';
92
- const connection: AmqpConnectionManager = await connect([`amqp://${host}`]);
104
+ const connection: AmqpConnectionManager = await this.connect([`amqp://${host}`]);
93
105
  this.connection = connection;
94
106
  this.connection.on('disconnect',
95
107
  ({ err }) => console.error(`${this.DISCONNECT_MSG}${err && ` - ${err}`}`));
@@ -109,7 +121,7 @@ class RabbitMq {
109
121
 
110
122
  try {
111
123
  if (this.channel === null) {
112
- this.channel = connection.createChannel({});
124
+ this.channel = await connection.createChannel({});
113
125
  }
114
126
  resolve(this.channel);
115
127
  } catch (e) {
@@ -0,0 +1,17 @@
1
+ interface RabbitWrapperInterface {
2
+ ack:any;
3
+ nack: any;
4
+ getConnection: any;
5
+ assertChannel: any;
6
+ assertExchange: any;
7
+ getQueueLength: any;
8
+ bindQueue: any;
9
+ assertQueue: any;
10
+ consume: any;
11
+ consumeFromExchange: any;
12
+ publish: any;
13
+ sendToQueue: any;
14
+
15
+ }
16
+
17
+ export default RabbitWrapperInterface;
@@ -0,0 +1,63 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment,@typescript-eslint/no-unused-vars */
2
+ import RabbitMq from '../index';
3
+
4
+ jest.setTimeout(120000);
5
+
6
+ const rabbit = new RabbitMq({ isTestEnv: true });
7
+
8
+ describe('RabbitMQ', () => {
9
+ it('check exchange', async () => {
10
+ const callback = (msg: any, ack: any) => {
11
+ expect(msg.content).toEqual('hey');
12
+ ack(msg);
13
+ };
14
+ const mockFn = jest.fn(callback);
15
+ await rabbit.consumeFromExchange('test-q2', 'test-e', mockFn);
16
+ await rabbit.publish('test-e', 'hey');
17
+ expect(mockFn).toBeCalled();
18
+ });
19
+
20
+ it('check queue', async () => {
21
+ const callback = (msg: any, ack: any) => {
22
+ expect(msg.content).toEqual('hey-q');
23
+ ack(msg);
24
+ };
25
+ const mockFn = jest.fn(callback);
26
+ await rabbit.consume('test-q-2', mockFn);
27
+ await rabbit.sendToQueue('test-q-2', 'hey-q');
28
+ expect(mockFn).toBeCalled();
29
+ });
30
+
31
+ it('cant publish to unknown exchange', async () => {
32
+ let err;
33
+ try {
34
+ await rabbit.publish('', 'hey');
35
+ } catch (e) {
36
+ err = e;
37
+ }
38
+ expect(err).toBeDefined();
39
+ });
40
+
41
+ it('get queue length', async () => {
42
+ const queueName = 'test-queue-length';
43
+ const exchangeName = 'test-e2';
44
+
45
+ await rabbit.assertQueue(queueName);
46
+ await rabbit.assertExchange(exchangeName);
47
+ await rabbit.bindQueue(queueName, exchangeName);
48
+
49
+ await rabbit.publish(exchangeName, 'hey');
50
+ let messageCount: any;
51
+ ({ messageCount } = await rabbit.getQueueLength(queueName));
52
+ expect(messageCount).toEqual(0);
53
+ await rabbit.publish(exchangeName, 'hey');
54
+ ({ messageCount } = await rabbit.getQueueLength(queueName));
55
+ expect(messageCount).toEqual(0);
56
+ await rabbit.consumeFromExchange(queueName, exchangeName, async (msg: any, ack: any) => {
57
+ expect(msg.content).toEqual('hey');
58
+ ack(msg);
59
+ });
60
+ ({ messageCount } = await rabbit.getQueueLength(queueName));
61
+ expect(messageCount).toEqual(0);
62
+ });
63
+ });
@@ -0,0 +1,132 @@
1
+ import * as Bluebird from 'bluebird';
2
+
3
+ let exchanges: any = {};
4
+ let queues: any = {};
5
+
6
+ export interface channel {
7
+ assertQueue: any;
8
+ assertExchange: any;
9
+ bindQueue: any;
10
+ publish: any;
11
+ consume: any;
12
+ deleteQueue: any;
13
+ ack: any;
14
+ nack: any;
15
+ prefetch: any;
16
+ on: any;
17
+ once: any;
18
+ close: any;
19
+ addSetup: any;
20
+ checkQueue: any;
21
+ sendToQueue: any;
22
+ }
23
+ export interface connection {
24
+ createChannel: any;
25
+ createConfirmChannel: any;
26
+ on: any;
27
+ once: any;
28
+ close: any;
29
+ }
30
+
31
+ const setIfUndef = (object: any, prop: any, value: any) => {
32
+ if (!object[prop]) {
33
+ // eslint-disable-next-line no-param-reassign
34
+ object[prop] = value;
35
+ }
36
+ };
37
+
38
+ class ChannelImpl implements channel {
39
+ public assertQueue = (queue: any, qOptions: any) => new Bluebird((resolve: () => any) => {
40
+ setIfUndef(queues, queue, { messages: [], subscribers: [], options: qOptions });
41
+ return resolve();
42
+ });
43
+
44
+ public assertExchange = (exchange: any, type: any, exchOptions: any = {}) => new Bluebird((resolve: () => any) => {
45
+ setIfUndef(exchanges, exchange, { bindings: [], options: exchOptions, type });
46
+
47
+ return resolve();
48
+ });
49
+
50
+ public bindQueue = (queue: any, exchange: string, key: string) => new Bluebird((resolve: () => any, reject: (arg0: string) => any) => {
51
+ if (!exchanges[exchange]) return reject(`Bind to non-existing exchange ${exchange}`);
52
+
53
+ const re = `^${key.replace('.', '\\.').replace('#', '(\\w|\\.)+').replace('*', '\\w+')}$`;
54
+ exchanges[exchange].bindings.push({ regex: new RegExp(re), queueName: queue });
55
+
56
+ return resolve();
57
+ });
58
+
59
+ public publish = (exchange: string, routingKey: any, content: any, props: any) => new Bluebird((resolve: () => any, reject: (arg0: string) => any) => {
60
+ if (!exchanges[exchange]) return reject(`Publish to non-existing exchange ${exchange}`);
61
+
62
+ const { bindings } = exchanges[exchange];
63
+ const matchingBindings = bindings.filter((b: any) => b.regex.test(routingKey));
64
+
65
+ matchingBindings.forEach((binding: { queueName: string | number; }) => {
66
+ const subscribers = queues[binding.queueName] ? queues[binding.queueName].subscribers : [];
67
+ subscribers.forEach((sub: (arg0: { fields: { routingKey: any; }; properties: any; content: any; }) => void) => {
68
+ const message = { fields: { routingKey }, properties: props, content };
69
+ sub(message);
70
+ });
71
+ });
72
+
73
+ return resolve();
74
+ });
75
+
76
+ public consume = (queue: string | number, handler: any) => {
77
+ queues[queue].subscribers.push(handler);
78
+ };
79
+
80
+ public sendToQueue = (queue: string, content: any, routingKey = '', props: any = {}) => {
81
+ const subscribers = queues[queue] ? queues[queue].subscribers : [];
82
+ subscribers.forEach((sub: (arg0: { fields: { routingKey: any; }; properties: any; content: any; }) => void) => {
83
+ const message = { fields: { routingKey }, properties: props, content };
84
+ sub(message);
85
+ });
86
+ };
87
+
88
+ public deleteQueue = (queue: string | number) => {
89
+ setImmediate(() => {
90
+ delete queues[queue];
91
+ });
92
+ };
93
+
94
+ public async addSetup(funcToRun: any) {
95
+ const val = await funcToRun(this);
96
+ return val;
97
+ }
98
+
99
+ public checkQueue = () => ({ messageCount: 0 });
100
+
101
+ public ack = () => null;
102
+
103
+ public nack = () => null;
104
+
105
+ public prefetch = () => null;
106
+
107
+ public on = () => null;
108
+
109
+ public once = () => null;
110
+
111
+ public close = () => Bluebird.resolve();
112
+ }
113
+
114
+ const createChannel = () => new Bluebird((resolve: any) => resolve(new ChannelImpl()));
115
+ export const connect = (): any => new Bluebird((resolve: any) => {
116
+ const connectionImpl: connection = {
117
+ createChannel,
118
+ createConfirmChannel: createChannel,
119
+ on: () => null,
120
+ once: () => null,
121
+ close: () => Bluebird.resolve(),
122
+ };
123
+
124
+ return resolve(connectionImpl);
125
+ });
126
+
127
+ const resetMock = () => {
128
+ queues = {};
129
+ exchanges = {};
130
+ };
131
+
132
+ module.exports = { connect, resetMock };