@imqueue/core 1.15.0 → 2.0.1

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.
@@ -1,10 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClusteredRedisQueue = void 0;
4
+ /*!
5
+ * Clustered messaging queue over Redis implementation
6
+ *
7
+ * I'm Queue Software Project
8
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
9
+ *
10
+ * This program is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ *
23
+ * If you want to use this code in a closed source (commercial) project, you can
24
+ * purchase a proprietary commercial license. Please contact us at
25
+ * <support@imqueue.com> to get commercial licensing options.
26
+ */
27
+ const events_1 = require("events");
4
28
  const _1 = require(".");
5
29
  /**
6
30
  * Class ClusteredRedisQueue
7
- * Implements possibility to scale queues horizontally between several
31
+ * Implements the possibility to scale queues horizontally between several
8
32
  * redis instances.
9
33
  */
10
34
  class ClusteredRedisQueue {
@@ -14,9 +38,10 @@ class ClusteredRedisQueue {
14
38
  * @constructor
15
39
  * @param {string} name
16
40
  * @param {Partial<IMQOptions>} options
17
- * @param {IMQMode} mode
41
+ * @param {IMQMode} [mode]
18
42
  */
19
43
  constructor(name, options, mode = _1.IMQMode.BOTH) {
44
+ var _a, _b;
20
45
  this.name = name;
21
46
  /**
22
47
  * RedisQueue instances collection
@@ -27,7 +52,7 @@ class ClusteredRedisQueue {
27
52
  /**
28
53
  * Cluster servers option definitions
29
54
  *
30
- * @type {{ host: string, port: number }[]}
55
+ * @type {IMessageQueueConnection[]}
31
56
  */
32
57
  // tslint:disable-next-line:completed-docs
33
58
  this.servers = [];
@@ -44,22 +69,34 @@ class ClusteredRedisQueue {
44
69
  * @type {number}
45
70
  */
46
71
  this.queueLength = 0;
72
+ this.state = {
73
+ started: false,
74
+ subscription: null,
75
+ };
76
+ this.templateEmitter = new events_1.EventEmitter();
77
+ this.clusterEmitter = new events_1.EventEmitter();
47
78
  this.options = (0, _1.buildOptions)(_1.DEFAULT_IMQ_OPTIONS, options);
48
79
  // istanbul ignore next
49
80
  this.logger = this.options.logger || console;
50
- if (!this.options.cluster) {
81
+ if (!this.options.cluster && !((_a = this.options.clusterManagers) === null || _a === void 0 ? void 0 : _a.length)) {
51
82
  throw new TypeError('ClusteredRedisQueue: cluster ' +
52
83
  'configuration is missing!');
53
84
  }
54
85
  this.mqOptions = Object.assign({}, this.options);
55
- // istanbul ignore next
56
- this.servers = this.mqOptions.cluster || [];
86
+ const cluster = [...this.mqOptions.cluster || []];
57
87
  delete this.mqOptions.cluster;
58
- for (let i = 0, s = this.servers.length; i < s; i++) {
59
- const opts = Object.assign(Object.assign({}, this.mqOptions), this.servers[i]);
60
- this.imqs.push(new _1.RedisQueue(this.name, opts));
88
+ for (const server of cluster) {
89
+ this.addServerWithQueueInitializing(server, false);
90
+ }
91
+ if ((_b = this.options.clusterManagers) === null || _b === void 0 ? void 0 : _b.length) {
92
+ for (const manager of this.options.clusterManagers) {
93
+ manager.init({
94
+ add: this.addServer.bind(this),
95
+ remove: this.removeServer.bind(this),
96
+ find: this.findServer.bind(this),
97
+ });
98
+ }
61
99
  }
62
- this.queueLength = this.imqs.length;
63
100
  }
64
101
  /**
65
102
  * Starts the messaging queue.
@@ -68,15 +105,17 @@ class ClusteredRedisQueue {
68
105
  * @returns {Promise<ClusteredRedisQueue>}
69
106
  */
70
107
  async start() {
108
+ this.state.started = true;
71
109
  return await this.batch('start', 'Starting clustered redis message queue...');
72
110
  }
73
111
  /**
74
- * Stops the queue (should stop handle queue messages).
112
+ * Stops the queue (should stop handling queue messages).
75
113
  * Supposed to be an async function.
76
114
  *
77
115
  * @returns {Promise<ClusteredRedisQueue>}
78
116
  */
79
117
  async stop() {
118
+ this.state.started = false;
80
119
  return await this.batch('stop', 'Stopping clustered redis message queue...');
81
120
  }
82
121
  /**
@@ -85,13 +124,18 @@ class ClusteredRedisQueue {
85
124
  *
86
125
  * @param {string} toQueue - queue name to which message should be sent to
87
126
  * @param {JsonObject} message - message data
88
- * @param {number} [delay] - if specified, message will be handled in the
89
- * target queue after specified period of time in milliseconds.
127
+ * @param {number} [delay] - if specified, a message will be handled in the
128
+ * target queue after a specified period of time in milliseconds.
90
129
  * @param {(err: Error) => void} [errorHandler] - callback called only when
91
130
  * internal error occurs during message send execution.
92
131
  * @returns {Promise<string>} - message identifier
93
132
  */
94
133
  async send(toQueue, message, delay, errorHandler) {
134
+ if (!this.queueLength) {
135
+ return await new Promise(resolve => this.clusterEmitter.once('initialized', async ({ imq }) => {
136
+ resolve(await imq.send(toQueue, message, delay, errorHandler));
137
+ }));
138
+ }
95
139
  if (this.currentQueue >= this.queueLength) {
96
140
  this.currentQueue = 0;
97
141
  }
@@ -108,6 +152,7 @@ class ClusteredRedisQueue {
108
152
  * @returns {Promise<void>}
109
153
  */
110
154
  async destroy() {
155
+ this.state.started = false;
111
156
  await this.batch('destroy', 'Destroying clustered redis message queue...');
112
157
  }
113
158
  // noinspection JSUnusedGlobalSymbols
@@ -141,7 +186,7 @@ class ClusteredRedisQueue {
141
186
  // EventEmitter interface
142
187
  // istanbul ignore next
143
188
  on(...args) {
144
- for (let imq of this.imqs) {
189
+ for (const imq of this.eventEmitters()) {
145
190
  imq.on.apply(imq, args);
146
191
  }
147
192
  return this;
@@ -149,56 +194,56 @@ class ClusteredRedisQueue {
149
194
  // istanbul ignore next
150
195
  // noinspection JSUnusedGlobalSymbols
151
196
  off(...args) {
152
- for (let imq of this.imqs) {
197
+ for (const imq of this.eventEmitters()) {
153
198
  imq.off.apply(imq, args);
154
199
  }
155
200
  return this;
156
201
  }
157
202
  // istanbul ignore next
158
203
  once(...args) {
159
- for (let imq of this.imqs) {
204
+ for (const imq of this.eventEmitters()) {
160
205
  imq.once.apply(imq, args);
161
206
  }
162
207
  return this;
163
208
  }
164
209
  // istanbul ignore next
165
210
  addListener(...args) {
166
- for (let imq of this.imqs) {
211
+ for (const imq of this.eventEmitters()) {
167
212
  imq.addListener.apply(imq, args);
168
213
  }
169
214
  return this;
170
215
  }
171
216
  // istanbul ignore next
172
217
  removeListener(...args) {
173
- for (let imq of this.imqs) {
218
+ for (const imq of this.eventEmitters()) {
174
219
  imq.removeListener.apply(imq, args);
175
220
  }
176
221
  return this;
177
222
  }
178
223
  // istanbul ignore next
179
224
  removeAllListeners(...args) {
180
- for (let imq of this.imqs) {
225
+ for (const imq of this.eventEmitters()) {
181
226
  imq.removeAllListeners.apply(imq, args);
182
227
  }
183
228
  return this;
184
229
  }
185
230
  // istanbul ignore next
186
231
  prependListener(...args) {
187
- for (let imq of this.imqs) {
232
+ for (const imq of this.eventEmitters()) {
188
233
  imq.prependListener.apply(imq, args);
189
234
  }
190
235
  return this;
191
236
  }
192
237
  // istanbul ignore next
193
238
  prependOnceListener(...args) {
194
- for (let imq of this.imqs) {
239
+ for (const imq of this.eventEmitters()) {
195
240
  imq.prependOnceListener.apply(imq, args);
196
241
  }
197
242
  return this;
198
243
  }
199
244
  // istanbul ignore next
200
245
  setMaxListeners(...args) {
201
- for (let imq of this.imqs) {
246
+ for (const imq of this.eventEmitters()) {
202
247
  imq.setMaxListeners.apply(imq, args);
203
248
  }
204
249
  return this;
@@ -206,7 +251,7 @@ class ClusteredRedisQueue {
206
251
  // istanbul ignore next
207
252
  listeners(...args) {
208
253
  let listeners = [];
209
- for (let imq of this.imqs) {
254
+ for (const imq of this.eventEmitters()) {
210
255
  listeners = listeners.concat(imq.listeners.apply(imq, args));
211
256
  }
212
257
  return listeners;
@@ -214,54 +259,135 @@ class ClusteredRedisQueue {
214
259
  // istanbul ignore next
215
260
  rawListeners(...args) {
216
261
  let rawListeners = [];
217
- for (let imq of this.imqs) {
262
+ for (const imq of this.eventEmitters()) {
218
263
  rawListeners = rawListeners.concat(imq.rawListeners.apply(imq, args));
219
264
  }
220
265
  return rawListeners;
221
266
  }
222
267
  // istanbul ignore next
223
268
  getMaxListeners() {
224
- return this.imqs[0].getMaxListeners();
269
+ return this.templateEmitter.getMaxListeners();
225
270
  }
226
271
  // istanbul ignore next
227
272
  emit(...args) {
228
- for (let imq of this.imqs) {
273
+ for (const imq of this.eventEmitters()) {
229
274
  imq.emit.apply(imq, args);
230
275
  }
231
276
  return true;
232
277
  }
233
278
  // istanbul ignore next
234
279
  eventNames(...args) {
235
- return this.imqs[0].eventNames.apply(this.imqs[0], args);
280
+ return this.templateEmitter.eventNames.apply(this.imqs[0], args);
236
281
  }
237
282
  // istanbul ignore next
238
283
  listenerCount(...args) {
239
- return this.imqs[0].listenerCount.apply(this.imqs[0], args);
284
+ return this.templateEmitter.listenerCount.apply(this.imqs[0], args);
240
285
  }
241
286
  // istanbul ignore next
242
287
  async publish(data, toName) {
243
288
  const promises = [];
244
- for (let imq of this.imqs) {
289
+ for (const imq of this.imqs) {
245
290
  promises.push(imq.publish(data, toName));
246
291
  }
247
292
  await Promise.all(promises);
248
293
  }
249
294
  // istanbul ignore next
250
295
  async subscribe(channel, handler) {
296
+ this.state.subscription = { channel, handler };
251
297
  const promises = [];
252
- for (let imq of this.imqs) {
298
+ for (const imq of this.imqs) {
253
299
  promises.push(imq.subscribe(channel, handler));
254
300
  }
255
301
  await Promise.all(promises);
256
302
  }
257
303
  // istanbul ignore next
258
304
  async unsubscribe() {
305
+ this.state.subscription = null;
259
306
  const promises = [];
260
- for (let imq of this.imqs) {
307
+ for (const imq of this.imqs) {
261
308
  promises.push(imq.unsubscribe());
262
309
  }
263
310
  await Promise.all(promises);
264
311
  }
312
+ /**
313
+ * Adds new servers to the cluster
314
+ *
315
+ * @param {IServerInput} server
316
+ * @returns {void}
317
+ */
318
+ addServer(server) {
319
+ return this.addServerWithQueueInitializing(server, true);
320
+ }
321
+ /**
322
+ * Removes server from the cluster
323
+ *
324
+ * @param {IServerInput} server
325
+ * @returns {void}
326
+ */
327
+ removeServer(server) {
328
+ const remove = this.findServer(server);
329
+ if (!remove) {
330
+ return;
331
+ }
332
+ if (remove.imq) {
333
+ this.imqs = this.imqs.filter(imq => remove.imq !== imq);
334
+ remove.imq.destroy().catch();
335
+ }
336
+ this.clusterEmitter.emit('remove', {
337
+ server: remove,
338
+ imq: remove.imq,
339
+ });
340
+ this.queueLength = this.imqs.length;
341
+ this.servers = this.servers.filter(existing => !ClusteredRedisQueue.matchServers(existing, server));
342
+ }
343
+ addServerWithQueueInitializing(server, initializeQueue = true) {
344
+ const newServer = {
345
+ id: server.id,
346
+ host: server.host,
347
+ port: server.port,
348
+ };
349
+ const opts = Object.assign(Object.assign({}, this.mqOptions), newServer);
350
+ const imq = new _1.RedisQueue(this.name, opts);
351
+ if (initializeQueue) {
352
+ this.initializeQueue(imq)
353
+ .then(() => {
354
+ this.clusterEmitter.emit('initialized', {
355
+ server: newServer,
356
+ imq,
357
+ });
358
+ })
359
+ .catch();
360
+ }
361
+ newServer.imq = imq;
362
+ this.imqs.push(imq);
363
+ this.servers.push(newServer);
364
+ this.clusterEmitter.emit('add', { server: newServer, imq });
365
+ this.queueLength = this.imqs.length;
366
+ }
367
+ eventEmitters() {
368
+ return [...this.imqs, this.templateEmitter];
369
+ }
370
+ async initializeQueue(imq) {
371
+ (0, _1.copyEventEmitter)(this.templateEmitter, imq);
372
+ if (this.state.started) {
373
+ await imq.start();
374
+ }
375
+ if (this.state.subscription) {
376
+ await imq.subscribe(this.state.subscription.channel, this.state.subscription.handler);
377
+ }
378
+ }
379
+ findServer(server) {
380
+ return this.servers.find(existing => ClusteredRedisQueue.matchServers(existing, server));
381
+ }
382
+ static matchServers(source, target) {
383
+ const sameAddress = target.host === source.host
384
+ && target.port === source.port;
385
+ if (!target.id && !source.id) {
386
+ return sameAddress;
387
+ }
388
+ const sameId = target.id === source.id;
389
+ return sameId || sameAddress;
390
+ }
265
391
  }
266
392
  exports.ClusteredRedisQueue = ClusteredRedisQueue;
267
393
  //# sourceMappingURL=ClusteredRedisQueue.js.map
package/src/IMQMode.d.ts CHANGED
@@ -1,17 +1,23 @@
1
1
  /*!
2
- * Copyright (c) 2018, imqueue.com <support@imqueue.com>
2
+ * I'm Queue Software Project
3
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
3
4
  *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
7
9
  *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- * PERFORMANCE OF THIS SOFTWARE.
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * If you want to use this code in a closed source (commercial) project, you can
19
+ * purchase a proprietary commercial license. Please contact us at
20
+ * <support@imqueue.com> to get commercial licensing options.
15
21
  */
16
22
  export declare enum IMQMode {
17
23
  BOTH = 0,
package/src/IMQMode.js CHANGED
@@ -2,19 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IMQMode = void 0;
4
4
  /*!
5
- * Copyright (c) 2018, imqueue.com <support@imqueue.com>
5
+ * I'm Queue Software Project
6
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
7
  *
7
- * Permission to use, copy, modify, and/or distribute this software for any
8
- * purpose with or without fee is hereby granted, provided that the above
9
- * copyright notice and this permission notice appear in all copies.
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
10
12
  *
11
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- * PERFORMANCE OF THIS SOFTWARE.
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ * If you want to use this code in a closed source (commercial) project, you can
22
+ * purchase a proprietary commercial license. Please contact us at
23
+ * <support@imqueue.com> to get commercial licensing options.
18
24
  */
19
25
  var IMQMode;
20
26
  (function (IMQMode) {
@@ -1,23 +1,29 @@
1
- /// <reference types="node" />
2
1
  /*!
3
2
  * Basic types and interfaces
4
3
  *
5
- * Copyright (c) 2018, imqueue.com <support@imqueue.com>
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
6
  *
7
- * Permission to use, copy, modify, and/or distribute this software for any
8
- * purpose with or without fee is hereby granted, provided that the above
9
- * copyright notice and this permission notice appear in all copies.
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
10
11
  *
11
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- * PERFORMANCE OF THIS SOFTWARE.
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
18
23
  */
19
24
  import { EventEmitter } from 'events';
20
25
  import { IMQMode } from './IMQMode';
26
+ import { ClusterManager } from './ClusterManager';
21
27
  export { EventEmitter } from 'events';
22
28
  /**
23
29
  * Represents any JSON-serializable value
@@ -101,35 +107,77 @@ export interface IMessage {
101
107
  */
102
108
  delay?: number;
103
109
  }
104
- /**
105
- * Message queue options
106
- */
107
- export interface IMQOptions {
110
+ export interface IServerInput {
108
111
  /**
109
- * Turns on/off cleanup of the message queues
112
+ * Message queue network unique identifier, optional property
110
113
  *
111
- * @type {boolean}
114
+ * @type {string | undefined}
112
115
  */
113
- cleanup: boolean;
116
+ id?: string;
114
117
  /**
115
- * Defines cleanup pattern for the name of the queue
116
- * which should be removed during cleanup processing
118
+ * Message queue network host
117
119
  *
118
120
  * @type {string}
119
121
  */
120
- cleanupFilter: string;
122
+ host: string;
123
+ /**
124
+ * Message queue network port
125
+ *
126
+ * @type {number}
127
+ */
128
+ port: number;
129
+ }
130
+ export interface IMessageQueueConnection extends IMessageQueueAuthConnection {
131
+ /**
132
+ * Message queue network unique identifier, optional property
133
+ *
134
+ * @type {string | undefined}
135
+ */
136
+ id?: string;
121
137
  /**
122
138
  * Message queue network host
123
139
  *
124
140
  * @type {string}
125
141
  */
126
- host?: string;
142
+ host: string;
127
143
  /**
128
144
  * Message queue network port
129
145
  *
130
146
  * @type {number}
131
147
  */
132
- port?: number;
148
+ port: number;
149
+ }
150
+ export interface IMessageQueueAuthConnection {
151
+ /**
152
+ * Message queue username
153
+ *
154
+ * @type {string}
155
+ */
156
+ username?: string;
157
+ /**
158
+ * Message queue password
159
+ *
160
+ * @type {string}
161
+ */
162
+ password?: string;
163
+ }
164
+ /**
165
+ * Message queue options
166
+ */
167
+ export interface IMQOptions extends Partial<IMessageQueueConnection> {
168
+ /**
169
+ * Turns on/off cleanup of the message queues
170
+ *
171
+ * @type {boolean}
172
+ */
173
+ cleanup: boolean;
174
+ /**
175
+ * Defines cleanup pattern for the name of the queue
176
+ * which should be removed during cleanup processing
177
+ *
178
+ * @type {string}
179
+ */
180
+ cleanupFilter: string;
133
181
  /**
134
182
  * Message queue vendor
135
183
  *
@@ -185,12 +233,20 @@ export interface IMQOptions {
185
233
  /**
186
234
  * Queue cluster instances, if MQ should be clustered
187
235
  *
188
- * @type {{host: string, port: number }[]}
236
+ * @type {IMessageQueueConnection[]}
237
+ */
238
+ cluster?: IMessageQueueConnection[];
239
+ /**
240
+ * Array of cluster managers used to handle cluster operations.
241
+ * Any manager implements specific cluster server detection.
242
+ *
243
+ * @type {ClusterManager[]}
189
244
  */
190
- cluster?: {
191
- host: string;
192
- port: number;
193
- }[];
245
+ clusterManagers?: ClusterManager[];
246
+ }
247
+ export interface EventMap {
248
+ message: [data: any, id: string, from: string];
249
+ error: [error: Error, eventName: string];
194
250
  }
195
251
  export type IMessageQueueConstructor = new (name: string, options?: Partial<IMQOptions>, mode?: IMQMode) => IMessageQueue;
196
252
  /**
@@ -228,7 +284,7 @@ export type IMessageQueueConstructor = new (name: string, options?: Partial<IMQO
228
284
  * }
229
285
  * ~~~
230
286
  */
231
- export interface IMessageQueue extends EventEmitter {
287
+ export interface IMessageQueue extends EventEmitter<EventMap> {
232
288
  /**
233
289
  * Message event. Occurs every time queue got a message.
234
290
  *