@imqueue/core 2.0.25 → 3.0.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.
Files changed (49) hide show
  1. package/.oxfmtrc.json +9 -0
  2. package/.oxlintrc.json +20 -0
  3. package/README.md +73 -63
  4. package/debug_getter.d.ts +1 -9
  5. package/index.d.ts +0 -1
  6. package/index.js +8 -9
  7. package/package.json +20 -67
  8. package/scripts/strip-comment-coverage.mjs +397 -0
  9. package/src/ClusterManager.d.ts +12 -3
  10. package/src/ClusterManager.js +21 -10
  11. package/src/ClusteredRedisQueue.d.ts +46 -14
  12. package/src/ClusteredRedisQueue.js +196 -169
  13. package/src/IMessageQueue.d.ts +89 -96
  14. package/src/IMessageQueue.js +2 -2
  15. package/src/RedisQueue.d.ts +193 -97
  16. package/src/RedisQueue.js +1328 -1070
  17. package/src/UDPClusterManager.d.ts +110 -26
  18. package/src/UDPClusterManager.js +227 -70
  19. package/src/UDPWorker.d.ts +53 -1
  20. package/src/UDPWorker.js +87 -46
  21. package/src/{promisify.d.ts → helpers/buildOptions.d.ts} +8 -15
  22. package/src/helpers/buildOptions.js +39 -0
  23. package/src/{copyEventEmitter.d.ts → helpers/copyEventEmitter.d.ts} +1 -1
  24. package/src/{copyEventEmitter.js → helpers/copyEventEmitter.js} +3 -4
  25. package/src/helpers/envInt.d.ts +32 -0
  26. package/src/helpers/envInt.js +39 -0
  27. package/src/helpers/escapeRegExp.d.ts +30 -0
  28. package/src/helpers/escapeRegExp.js +36 -0
  29. package/src/helpers/index.d.ts +31 -0
  30. package/src/helpers/index.js +48 -0
  31. package/src/helpers/pack.d.ts +7 -0
  32. package/src/helpers/pack.js +37 -0
  33. package/src/helpers/randomInt.d.ts +31 -0
  34. package/src/helpers/randomInt.js +37 -0
  35. package/src/helpers/sha1.d.ts +7 -0
  36. package/src/helpers/sha1.js +39 -0
  37. package/src/helpers/unpack.d.ts +7 -0
  38. package/src/helpers/unpack.js +37 -0
  39. package/src/index.d.ts +1 -14
  40. package/src/index.js +1 -19
  41. package/src/profile.d.ts +28 -38
  42. package/src/profile.js +100 -95
  43. package/src/redis.d.ts +1 -1
  44. package/src/redis.js +4 -2
  45. package/typedoc.json +19 -0
  46. package/eslint.config.mjs +0 -98
  47. package/src/promisify.js +0 -106
  48. package/src/uuid.d.ts +0 -6
  49. package/src/uuid.js +0 -65
@@ -0,0 +1,397 @@
1
+ /*!
2
+ * Coverage post-processor
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
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.
11
+ *
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.
23
+ */
24
+
25
+ /**
26
+ * Node's built-in coverage (`--experimental-test-coverage --enable-source-maps`)
27
+ * reports every non-code line of a `.ts` source as uncovered, because comment
28
+ * and blank lines have no source-map mappings and therefore fall outside every
29
+ * covered V8 byte-range. That paints the license header and each JSDoc block
30
+ * red in the HTML report and pushes per-file line% far below reality.
31
+ *
32
+ * Node's reporter also emits records that the (strict) genhtml LCOV 2.x tool
33
+ * rejects — function entries with `undefined` line numbers or synthetic,
34
+ * duplicated names (`<instance_members_initializer>`, and decorated methods all
35
+ * mis-named `has`/`get`), plus `BRDA:undefined,...` branch records. Left in,
36
+ * they produce a wall of warnings and a fatal "unexpected category" error.
37
+ *
38
+ * This script rewrites an lcov file in place: it drops the `DA`/`BRDA` records
39
+ * for lines that contain no executable code (comments and blank lines), drops
40
+ * all function records and malformed branch records, then recomputes the
41
+ * `LF`/`LH`/`BRF`/`BRH` totals. It uses the TypeScript scanner (already a dev
42
+ * dependency) to locate comments reliably — comment markers inside strings,
43
+ * template literals and regexes are not misdetected. The result renders in
44
+ * genhtml with accurate line + branch coverage and no warnings or errors.
45
+ */
46
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
47
+ import ts from 'typescript';
48
+
49
+ const lcovPath = process.argv[2] || 'coverage/lcov.info';
50
+
51
+ if (!existsSync(lcovPath)) {
52
+ console.warn(`strip-comment-coverage: ${lcovPath} not found, skipping`);
53
+ process.exit(0);
54
+ }
55
+
56
+ /**
57
+ * Returns the set of 1-based line numbers in the given source that hold no
58
+ * executable code — i.e. blank lines and lines whose only content is a comment.
59
+ *
60
+ * @param {string} text
61
+ * @returns {Set<number>}
62
+ */
63
+ function nonCodeLines(text) {
64
+ const commentChars = new Uint8Array(text.length);
65
+ const scanner = ts.createScanner(
66
+ ts.ScriptTarget.Latest,
67
+ /* skipTrivia */ false,
68
+ ts.LanguageVariant.Standard,
69
+ text,
70
+ );
71
+
72
+ let token = scanner.scan();
73
+
74
+ while (token !== ts.SyntaxKind.EndOfFileToken) {
75
+ if (
76
+ token === ts.SyntaxKind.SingleLineCommentTrivia ||
77
+ token === ts.SyntaxKind.MultiLineCommentTrivia
78
+ ) {
79
+ const start = scanner.getTokenStart();
80
+ const end = scanner.getTokenEnd();
81
+
82
+ for (let i = start; i < end; i++) {
83
+ commentChars[i] = 1;
84
+ }
85
+ }
86
+
87
+ token = scanner.scan();
88
+ }
89
+
90
+ const lines = text.split('\n');
91
+ const result = new Set();
92
+ let pos = 0;
93
+
94
+ for (let ln = 0; ln < lines.length; ln++) {
95
+ const line = lines[ln];
96
+ let hasCode = false;
97
+
98
+ for (let i = 0; i < line.length; i++) {
99
+ const ch = line[i];
100
+
101
+ if (ch === ' ' || ch === '\t' || ch === '\r') {
102
+ continue;
103
+ }
104
+
105
+ if (!commentChars[pos + i]) {
106
+ hasCode = true;
107
+ break;
108
+ }
109
+ }
110
+
111
+ if (!hasCode) {
112
+ result.add(ln + 1);
113
+ }
114
+
115
+ pos += line.length + 1; // account for the split '\n'
116
+ }
117
+
118
+ return result;
119
+ }
120
+
121
+ /**
122
+ * Returns the set of 1-based lines occupied by top-level import statements.
123
+ * Imports compile to `require(...)` that runs on module load, so they are
124
+ * always executed, yet Node's source-mapped coverage frequently mis-reports
125
+ * them as uncovered (the mapping lands outside the covered byte-range). Treating
126
+ * them as non-coverable corrects that artifact rather than hiding real logic.
127
+ *
128
+ * @param {string} text
129
+ * @returns {Set<number>}
130
+ */
131
+ function importLines(text) {
132
+ const sf = ts.createSourceFile(
133
+ 'x.ts',
134
+ text,
135
+ ts.ScriptTarget.Latest,
136
+ false,
137
+ );
138
+ const result = new Set();
139
+
140
+ for (const stmt of sf.statements) {
141
+ if (
142
+ ts.isImportDeclaration(stmt) ||
143
+ ts.isImportEqualsDeclaration(stmt)
144
+ ) {
145
+ const from = sf.getLineAndCharacterOfPosition(stmt.getStart(sf)).line;
146
+ const to = sf.getLineAndCharacterOfPosition(stmt.getEnd()).line;
147
+
148
+ for (let line = from; line <= to; line++) {
149
+ result.add(line + 1);
150
+ }
151
+ }
152
+ }
153
+
154
+ return result;
155
+ }
156
+
157
+ const B64 =
158
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
159
+ const B64MAP = new Map([...B64].map((c, i) => [c, i]));
160
+
161
+ /**
162
+ * Decodes one base64 VLQ source-map segment into its integer fields.
163
+ *
164
+ * @param {string} seg
165
+ * @returns {number[]}
166
+ */
167
+ function decodeVLQ(seg) {
168
+ const out = [];
169
+ let shift = 0;
170
+ let value = 0;
171
+
172
+ for (const ch of seg) {
173
+ const digit = B64MAP.get(ch);
174
+
175
+ if (digit === undefined) {
176
+ break;
177
+ }
178
+
179
+ value += (digit & 31) << shift;
180
+
181
+ if (digit & 32) {
182
+ shift += 5;
183
+ } else {
184
+ out.push(value & 1 ? -(value >> 1) : value >> 1);
185
+ value = 0;
186
+ shift = 0;
187
+ }
188
+ }
189
+
190
+ return out;
191
+ }
192
+
193
+ /**
194
+ * Returns the set of 1-based source lines that produced generated JavaScript,
195
+ * read from the file's `.js.map`. These are exactly the coverable lines — every
196
+ * other line (comments, blanks, type-only declarations, interfaces) emits no
197
+ * code and can never be executed. Returns null when no source map is present.
198
+ *
199
+ * @param {string} sourceFile - path of the .ts source (e.g. src/RedisQueue.ts)
200
+ * @returns {Set<number> | null}
201
+ */
202
+ function emittedLines(sourceFile) {
203
+ const mapPath = sourceFile.replace(/\.ts$/, '.js.map');
204
+
205
+ if (!existsSync(mapPath)) {
206
+ return null;
207
+ }
208
+
209
+ let map;
210
+
211
+ try {
212
+ map = JSON.parse(readFileSync(mapPath, 'utf8'));
213
+ } catch {
214
+ return null;
215
+ }
216
+
217
+ if (typeof map.mappings !== 'string') {
218
+ return null;
219
+ }
220
+
221
+ const lines = new Set();
222
+ let srcIndex = 0;
223
+ let srcLine = 0;
224
+
225
+ for (const group of map.mappings.split(';')) {
226
+ for (const seg of group.split(',')) {
227
+ if (!seg) {
228
+ continue;
229
+ }
230
+
231
+ const fields = decodeVLQ(seg);
232
+
233
+ // [genCol, srcIndex, srcLine, srcCol, nameIndex]; <4 fields = no
234
+ // source position for this segment
235
+ if (fields.length >= 4) {
236
+ srcIndex += fields[1];
237
+ srcLine += fields[2];
238
+
239
+ if (srcIndex === 0) {
240
+ lines.add(srcLine + 1); // map lines are 0-based
241
+ }
242
+ }
243
+ }
244
+ }
245
+
246
+ return lines;
247
+ }
248
+
249
+ const coverableCache = new Map();
250
+
251
+ /**
252
+ * Resolves how to filter a source file's line records:
253
+ * - `{ mode: 'keep', set }` — keep only lines in `set` (source-map driven);
254
+ * - `{ mode: 'drop', set }` — drop lines in `set` (comment-scanner fallback).
255
+ *
256
+ * @param {string} sourceFile
257
+ * @returns {{ mode: 'keep' | 'drop', set: Set<number> }}
258
+ */
259
+ function coverableInfo(sourceFile) {
260
+ if (coverableCache.has(sourceFile)) {
261
+ return coverableCache.get(sourceFile);
262
+ }
263
+
264
+ const emitted = sourceFile ? emittedLines(sourceFile) : null;
265
+ let info;
266
+
267
+ if (emitted && existsSync(sourceFile)) {
268
+ // A line is coverable only if it emitted JS (has a source-map mapping)
269
+ // AND is not a comment/blank AND is not an import statement. The comment
270
+ // check is required because `removeComments: false` keeps license/JSDoc
271
+ // comments in the output, so they carry mappings too; the mapping check
272
+ // drops type-only lines (interfaces, type aliases) which emit nothing;
273
+ // the import check drops the mis-mapped import artifact.
274
+ const text = readFileSync(sourceFile, 'utf8');
275
+ const nonCode = nonCodeLines(text);
276
+ const imports = importLines(text);
277
+ const keep = new Set(
278
+ [...emitted].filter(
279
+ line => !nonCode.has(line) && !imports.has(line),
280
+ ),
281
+ );
282
+ info = { mode: 'keep', set: keep };
283
+ } else if (sourceFile && existsSync(sourceFile)) {
284
+ const text = readFileSync(sourceFile, 'utf8');
285
+ const skip = nonCodeLines(text);
286
+
287
+ for (const line of importLines(text)) {
288
+ skip.add(line);
289
+ }
290
+
291
+ info = { mode: 'drop', set: skip };
292
+ } else {
293
+ info = { mode: 'drop', set: new Set() };
294
+ }
295
+
296
+ coverableCache.set(sourceFile, info);
297
+
298
+ return info;
299
+ }
300
+
301
+ let strippedLines = 0;
302
+
303
+ /**
304
+ * Rewrites a single lcov record so that genhtml accepts it without warnings or
305
+ * errors. It:
306
+ * - drops DA/BRDA entries on non-code (comment/blank) lines;
307
+ * - drops all function records (FN/FNDA/FNF/FNH) — Node's source-mapped
308
+ * function detection is unreliable here (undefined line numbers, mis-named
309
+ * and duplicated entries), which genhtml rejects, so line + branch coverage
310
+ * is kept instead;
311
+ * - drops malformed branch records such as `BRDA:undefined,...`;
312
+ * - recomputes the LF/LH/BRF/BRH totals.
313
+ *
314
+ * @param {string[]} recordLines - record body, excluding the end_of_record line
315
+ * @returns {string}
316
+ */
317
+ function processRecord(recordLines) {
318
+ const sfLine = recordLines.find(line => line.startsWith('SF:'));
319
+ const sourceFile = sfLine ? sfLine.slice(3).trim() : '';
320
+ const info = coverableInfo(sourceFile);
321
+
322
+ // true when a source line produces no executable code and must be dropped
323
+ const drop = n => (info.mode === 'keep' ? !info.set.has(n) : info.set.has(n));
324
+
325
+ let lf = 0;
326
+ let lh = 0;
327
+ let brf = 0;
328
+ let brh = 0;
329
+
330
+ const kept = recordLines.filter(line => {
331
+ // drop all function records — unreliable under source maps
332
+ if (/^(FN:|FNDA:|FNF:|FNH:)/.test(line)) {
333
+ return false;
334
+ }
335
+
336
+ const da = line.match(/^DA:(\d+),(\d+)/);
337
+
338
+ if (da) {
339
+ if (drop(+da[1])) {
340
+ strippedLines++;
341
+
342
+ return false;
343
+ }
344
+
345
+ lf++;
346
+
347
+ if (+da[2] > 0) {
348
+ lh++;
349
+ }
350
+
351
+ return true;
352
+ }
353
+
354
+ if (line.startsWith('BRDA:')) {
355
+ const brda = line.match(/^BRDA:(\d+),\d+,\d+,(\d+|-)$/);
356
+
357
+ // drop malformed (e.g. BRDA:undefined,...) or non-code branches
358
+ if (!brda || drop(+brda[1])) {
359
+ return false;
360
+ }
361
+
362
+ brf++;
363
+
364
+ if (brda[2] !== '-' && +brda[2] > 0) {
365
+ brh++;
366
+ }
367
+
368
+ return true;
369
+ }
370
+
371
+ // drop the old totals — they are recomputed below
372
+ return !/^(LF|LH|BRF|BRH):/.test(line);
373
+ });
374
+
375
+ return (
376
+ `${kept.join('\n')}\n` +
377
+ `LF:${lf}\nLH:${lh}\nBRF:${brf}\nBRH:${brh}\nend_of_record\n`
378
+ );
379
+ }
380
+
381
+ const output = [];
382
+ let record = [];
383
+
384
+ for (const line of readFileSync(lcovPath, 'utf8').split('\n')) {
385
+ if (line === 'end_of_record') {
386
+ output.push(processRecord(record));
387
+ record = [];
388
+ } else if (line !== '') {
389
+ record.push(line);
390
+ }
391
+ }
392
+
393
+ writeFileSync(lcovPath, output.join(''));
394
+ console.info(
395
+ `strip-comment-coverage: removed ${strippedLines} comment/blank line ` +
396
+ `entries from ${lcovPath}`,
397
+ );
@@ -23,9 +23,9 @@
23
23
  */
24
24
  import { IMessageQueueConnection, IServerInput } from './IMessageQueue';
25
25
  export interface ICluster {
26
- add: <T extends IMessageQueueConnection>(server: IServerInput) => T;
26
+ add: (server: IServerInput) => IMessageQueueConnection;
27
27
  remove: (server: IServerInput) => void;
28
- find: <T extends IMessageQueueConnection>(server: IServerInput) => T | undefined;
28
+ find: (server: IServerInput) => IMessageQueueConnection | undefined;
29
29
  }
30
30
  export interface InitializedCluster extends ICluster {
31
31
  id: string;
@@ -34,7 +34,16 @@ export declare abstract class ClusterManager {
34
34
  protected clusters: InitializedCluster[];
35
35
  protected constructor();
36
36
  init(cluster: ICluster): InitializedCluster;
37
- anyCluster(fn: (cluster: InitializedCluster) => Promise<void> | void): Promise<void>;
37
+ /**
38
+ * Applies the given callback to every registered cluster. Each cluster
39
+ * is handled independently: a callback that throws (synchronously or
40
+ * asynchronously) for one cluster never prevents the remaining clusters
41
+ * from being processed.
42
+ *
43
+ * @param {(cluster: InitializedCluster) => Promise<void> | void} fn
44
+ * @returns {Promise<void>}
45
+ */
46
+ forEachCluster(fn: (cluster: InitializedCluster) => Promise<void> | void): Promise<void>;
38
47
  remove(cluster: string | InitializedCluster, destroy?: boolean): Promise<void>;
39
48
  abstract destroy(): Promise<void>;
40
49
  }
@@ -1,25 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClusterManager = void 0;
4
- const uuid_1 = require("./uuid");
4
+ const node_crypto_1 = require("node:crypto");
5
5
  class ClusterManager {
6
- constructor() {
7
- this.clusters = [];
8
- }
6
+ clusters = [];
7
+ constructor() { }
9
8
  init(cluster) {
10
- const initializedCluster = Object.assign(cluster, { id: (0, uuid_1.uuid)() });
9
+ const initializedCluster = {
10
+ ...cluster,
11
+ id: (0, node_crypto_1.randomUUID)(),
12
+ };
11
13
  this.clusters.push(initializedCluster);
12
14
  return initializedCluster;
13
15
  }
14
- async anyCluster(fn) {
15
- await Promise.all(this.clusters.map(cluster => fn(cluster)));
16
+ /**
17
+ * Applies the given callback to every registered cluster. Each cluster
18
+ * is handled independently: a callback that throws (synchronously or
19
+ * asynchronously) for one cluster never prevents the remaining clusters
20
+ * from being processed.
21
+ *
22
+ * @param {(cluster: InitializedCluster) => Promise<void> | void} fn
23
+ * @returns {Promise<void>}
24
+ */
25
+ async forEachCluster(fn) {
26
+ await Promise.allSettled(this.clusters.map(async (cluster) => fn(cluster)));
16
27
  }
17
28
  async remove(cluster, destroy = true) {
18
29
  const id = typeof cluster === 'string' ? cluster : cluster.id;
19
30
  this.clusters = this.clusters.filter(cluster => cluster.id !== id);
20
- if (this.clusters.length === 0
21
- && destroy
22
- && typeof this.destroy === 'function') {
31
+ if (this.clusters.length === 0 &&
32
+ destroy &&
33
+ typeof this.destroy === 'function') {
23
34
  await this.destroy();
24
35
  }
25
36
  }
@@ -21,14 +21,14 @@
21
21
  * purchase a proprietary commercial license. Please contact us at
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
- import { EventEmitter } from 'events';
24
+ import { EventEmitter } from 'node:events';
25
25
  import { EventMap, ILogger, IMessageQueue, IMessageQueueConnection, IMQMode, IMQOptions, IServerInput, JsonObject, RedisQueue } from '.';
26
26
  interface ClusterServer extends IMessageQueueConnection {
27
27
  imq?: RedisQueue;
28
28
  }
29
29
  /**
30
30
  * Class ClusteredRedisQueue
31
- * Implements the possibility to scale queues horizontally between several
31
+ Implements the possibility to scale queues horizontally between several
32
32
  * redis instances.
33
33
  */
34
34
  export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<EventMap> {
@@ -70,6 +70,10 @@ export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<
70
70
  * @type {number}
71
71
  */
72
72
  private currentQueue;
73
+ /**
74
+ * Time (ms) send() waits for the first server when the cluster is empty
75
+ */
76
+ private readonly sendInitTimeout;
73
77
  /**
74
78
  * Total length of RedisQueue instances
75
79
  *
@@ -95,12 +99,11 @@ export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<
95
99
  /**
96
100
  * Class constructor
97
101
  *
98
- * @constructor
99
102
  * @param {string} name
100
103
  * @param {Partial<IMQOptions>} options
101
- * @param {IMQMode} [mode]
104
+ * @param {IMQMode} [_mode]
102
105
  */
103
- constructor(name: string, options?: Partial<IMQOptions>, mode?: IMQMode);
106
+ constructor(name: string, options?: Partial<IMQOptions>, _mode?: IMQMode);
104
107
  /**
105
108
  * Starts the messaging queue.
106
109
  * Supposed to be an async function.
@@ -116,18 +119,35 @@ export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<
116
119
  */
117
120
  stop(): Promise<ClusteredRedisQueue>;
118
121
  /**
119
- * Sends a message to given queue name with the given data.
122
+ * Sends a message to a given queue name with the given data.
120
123
  * Supposed to be an async function.
121
124
  *
122
- * @param {string} toQueue - queue name to which message should be sent to
125
+ * @param {string} toQueue - queue name to which a message should be sent to
123
126
  * @param {JsonObject} message - message data
124
127
  * @param {number} [delay] - if specified, a message will be handled in the
125
- * target queue after a specified period of time in milliseconds.
128
+ target queue after a specified period of time in milliseconds.
126
129
  * @param {(err: Error) => void} [errorHandler] - callback called only when
127
- * internal error occurs during message send execution.
130
+ internal error occurs during message send execution.
128
131
  * @returns {Promise<string>} - message identifier
129
132
  */
130
133
  send(toQueue: string, message: JsonObject, delay?: number, errorHandler?: (err: Error) => void): Promise<string>;
134
+ /**
135
+ * Picks the next queue for a round-robin send, preferring an instance
136
+ * whose redis connection is currently ready so messages are not routed
137
+ * to a host that is known to be down. Falls back to the plain
138
+ * round-robin pick when no instance reports are ready.
139
+ *
140
+ * @returns {RedisQueue}
141
+ */
142
+ private selectQueue;
143
+ /**
144
+ * Sends a message once the first cluster server becomes available.
145
+ * Rejects (rather than hanging forever) if none appears within the
146
+ * configured timeout and propagates any sent failure.
147
+ *
148
+ * @returns {Promise<string>}
149
+ */
150
+ private sendWhenInitialized;
131
151
  /**
132
152
  * Safely destroys the current queue, unregistered all set event
133
153
  * listeners and connections.
@@ -144,15 +164,27 @@ export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<
144
164
  */
145
165
  clear(): Promise<ClusteredRedisQueue>;
146
166
  queueLength(): Promise<number>;
167
+ private verbose;
147
168
  /**
148
169
  * Batch imq action processing on all registered imqs at once
149
170
  *
150
- * @access private
151
171
  * @param {string} action
152
172
  * @param {string} message
153
- * @return {Promise<this>}
173
+ * @returns {Promise<this>}
154
174
  */
155
175
  private batch;
176
+ /**
177
+ * Applies the named EventEmitter method to every underlying emitter,
178
+ * forwarding the call across the whole cluster. Dispatch is reflective
179
+ * (method chosen by name), so a single contained cast bridges the dynamic
180
+ * call while the public method signatures below stay fully typed.
181
+ *
182
+ * @template K - EventEmitter method name
183
+ * @param {K} method - name of the EventEmitter method to invoke
184
+ * @param {any[]} args - arguments to pass to the method
185
+ * @returns {unknown[]} - results from each emitter call
186
+ */
187
+ private applyToEmitters;
156
188
  on(...args: any[]): this;
157
189
  off(...args: any[]): this;
158
190
  once(...args: any[]): this;
@@ -166,10 +198,10 @@ export declare class ClusteredRedisQueue implements IMessageQueue, EventEmitter<
166
198
  rawListeners(...args: any[]): any[];
167
199
  getMaxListeners(): number;
168
200
  emit(...args: any[]): boolean;
169
- eventNames(...args: any[]): any;
170
- listenerCount(...args: any[]): any;
201
+ eventNames(): (keyof EventMap)[];
202
+ listenerCount(...args: any[]): number;
171
203
  publish(data: JsonObject, toName?: string): Promise<void>;
172
- subscribe(channel: string, handler: (data: JsonObject) => any): Promise<void>;
204
+ subscribe(channel: string, handler: (data: JsonObject) => void): Promise<void>;
173
205
  unsubscribe(): Promise<void>;
174
206
  /**
175
207
  * Adds new servers to the cluster