@imqueue/core 3.2.5 → 3.3.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.
@@ -23,103 +23,150 @@
23
23
  */
24
24
  import { EventEmitter } from 'node:events';
25
25
  import { type IMessageQueue, type JsonObject, type IMQOptions, IMQMode, type EventMap } from './index.js';
26
+ /**
27
+ * Default option values applied to every queue instance: `localhost:6379`,
28
+ * prefix `imq`, `console` as the logger, cleanup off with filter `'*'`, safe
29
+ * delivery off with a 5000 ms lease TTL, gzip off, a 5000 ms watcher check
30
+ * interval, and process signal handling on.
31
+ *
32
+ * @remarks
33
+ * Constructor options are shallow-merged over this object, so passing an explicit
34
+ * `undefined` overrides a default rather than falling back to it.
35
+ *
36
+ * The object is exported live and is not frozen — mutating it changes the
37
+ * defaults for every queue constructed afterwards in the process. Prefer
38
+ * per-instance options.
39
+ */
26
40
  export declare const DEFAULT_IMQ_OPTIONS: IMQOptions;
41
+ /**
42
+ * Time in milliseconds allowed for releasing watcher locks when a shutdown
43
+ * signal is received, before the process is force-exited. Defaults to 1000;
44
+ * override with the `IMQ_SHUTDOWN_TIMEOUT` environment variable.
45
+ *
46
+ * @remarks
47
+ * This is not a drain period — running `message` handlers are not awaited.
48
+ * The value is read once when the module is loaded, and a non-numeric value falls
49
+ * back to the default. Relevant only while {@link IMQOptions.handleSignals} is
50
+ * enabled.
51
+ */
27
52
  export declare const IMQ_SHUTDOWN_TIMEOUT: number;
28
53
  /**
29
54
  * Grace period (ms) for a graceful QUIT to complete before a channel is
30
55
  * forcibly disconnected. A reader blocked on an infinite BRPOP/BLMOVE can
31
56
  * never let QUIT through, so without this the socket would leak and keep
32
57
  * the process alive.
58
+ *
59
+ * @remarks
60
+ * Defaults to 1000; override with the `IMQ_CONNECTION_QUIT_TIMEOUT` environment
61
+ * variable, which is read once when the module is loaded. Applies to the writer,
62
+ * watcher and subscription channels — the reader is disconnected immediately
63
+ * without attempting `QUIT`.
33
64
  */
34
65
  export declare const IMQ_CONNECTION_QUIT_TIMEOUT: number;
35
66
  /**
36
- * Class RedisQueue
37
- * Implements a simple messaging queue over redis.
67
+ * Redis-backed message queue with at-least-once delivery — the default
68
+ * {@link IMessageQueue} implementation, and what {@link IMQ.create} returns for a
69
+ * single-server configuration.
70
+ *
71
+ * @remarks
72
+ * Connection model: the reader is per instance and exists only in
73
+ * {@link IMQMode.BOTH} or {@link IMQMode.WORKER} mode, while the writer and
74
+ * watcher connections are shared per `host:port` across every queue in the
75
+ * process and reference-counted. Exactly one queue per key prefix is elected as
76
+ * the watcher through a `<prefix>:watch:lock` key, and that owner also releases
77
+ * delayed messages, recovers abandoned safe-delivery hand-offs and — when
78
+ * {@link IMQOptions.cleanup} is on — prunes orphaned keys.
79
+ *
80
+ * Lifecycle: {@link RedisQueue.start} is required before consuming or
81
+ * publishing, while {@link RedisQueue.send} starts the queue lazily.
82
+ * {@link RedisQueue.stop} only stops consuming; use
83
+ * {@link RedisQueue.destroy} to release the watcher lock, the timers and the
84
+ * connections.
85
+ *
86
+ * Reconnection is handled by the queue itself — ioredis's own retry strategy is
87
+ * disabled in favour of a capped exponential backoff from 1 s to 30 s per
88
+ * channel.
89
+ *
90
+ * Events (typed by {@link EventMap}): `message`, with the payload, the message id
91
+ * and the sending queue's name; and `error`, with the error and the name of the
92
+ * internal routine that caught it (`OnMessage`, `OnProcessDelayed`,
93
+ * `OnSafeDelivery`, `OnWatch`, `OnConfig`, `OnScriptLoad`, `OnReadUnsafe` or
94
+ * `OnReadSafe`). Background errors are emitted only when at least one `error`
95
+ * listener is attached — otherwise they are logged and swallowed, so attach one
96
+ * if you need to observe them.
38
97
  */
39
98
  export declare class RedisQueue extends EventEmitter<EventMap> implements IMessageQueue {
99
+ /**
100
+ * The queue name. The underlying redis list key is `<prefix>:<name>`, the
101
+ * same name is the default pub/sub channel used by
102
+ * {@link RedisQueue.publish}, and it is the `from` value carried by
103
+ * messages this queue sends.
104
+ *
105
+ * @remarks
106
+ * Assign it before {@link RedisQueue.start} — a running reader keeps
107
+ * consuming the key it was started with.
108
+ */
40
109
  name: string;
41
110
  private readonly mode;
42
111
  /**
43
112
  * Writer connections collection
44
- *
45
- * @type {{}}
46
113
  */
47
114
  private static writers;
48
115
  /**
49
116
  * Watcher connections collection
50
- *
51
- * @type {{}}
52
117
  */
53
118
  private static watchers;
54
119
  /**
55
120
  * Number of started queue instances per shared writer connection key
56
- *
57
- * @type {{}}
58
121
  */
59
122
  private static writerRefs;
60
123
  /**
61
124
  * All started queue instances within the current process
62
- *
63
- * @type {Set<RedisQueue>}
64
125
  */
65
126
  private static readonly instances;
66
127
  /**
67
128
  * True when process-level signal handlers were bound
68
- *
69
- * @type {boolean}
70
129
  */
71
130
  private static signalsBound;
72
131
  /**
73
- * @event message (message: JsonObject, id: string, from: string)
74
- */
75
- /**
76
- * This queue instance options
132
+ * The effective options for this queue: {@link DEFAULT_IMQ_OPTIONS} merged
133
+ * with the values passed to the constructor.
77
134
  *
78
- * @type {IMQOptions}
135
+ * @remarks
136
+ * Treat this as read-only configuration. Some options are captured at
137
+ * construction time — `useGzip`, `host` and `port` — so changing them here has
138
+ * no effect, while `safeDelivery`, `safeDeliveryTtl`, `cleanup`,
139
+ * `cleanupFilter` and `verbose` are re-read at runtime.
79
140
  */
80
141
  options: IMQOptions;
81
142
  /**
82
143
  * Reader connection associated with this queue instance
83
- *
84
- * @type {IRedisClient}
85
144
  */
86
145
  private reader?;
87
146
  /**
88
147
  * Channel connection associated with this queue instance
89
148
  * Specially designed for client subscriptions to server-emitted events
90
- *
91
- * @type {IRedisClient}
92
149
  */
93
150
  private subscription?;
94
151
  /**
95
152
  * Channel name for subscriptions
96
- *
97
- * @type {string}
98
153
  */
99
154
  private subscriptionName?;
100
155
  /**
101
156
  * Init state for this queue instance
102
- *
103
- * @type {boolean}
104
157
  */
105
158
  private initialized;
106
159
  /**
107
160
  * Signals if the queue was destroyed
108
- *
109
- * @type {boolean}
110
161
  */
111
162
  private destroyed;
112
163
  /**
113
164
  * True if the current instance owns a watcher connection, false otherwise
114
- *
115
- * @type {boolean}
116
165
  */
117
166
  private watchOwner;
118
167
  /**
119
168
  * Subscription handlers registered through subscribe(). Kept to be
120
169
  * able to restore the subscription after a connection replacement.
121
- *
122
- * @type {Array<(data: JsonObject) => void>}
123
170
  */
124
171
  private subscriptionHandlers;
125
172
  /**
@@ -151,65 +198,110 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
151
198
  private reconnectAttempts;
152
199
  private reconnecting;
153
200
  /**
154
- * This queue instance unique key (identifier), for internal use
201
+ * The `host:port` address of the redis server this queue talks to.
202
+ *
203
+ * @remarks
204
+ * This is not an instance identifier. It is deliberately shared by every
205
+ * queue in the process that targets the same server, and is the key under
206
+ * which the writer and watcher connections (and the writer reference count)
207
+ * are stored. It includes neither the key prefix nor the credentials, so two
208
+ * queues differing only in those share the same underlying connections — the
209
+ * first one created wins.
155
210
  */
156
211
  readonly redisKey: string;
157
212
  /**
158
213
  * Lua scripts for redis
159
- *
160
- * @type {{moveDelayed: {code: string}}}
161
214
  */
162
215
  private scripts;
163
216
  /**
164
217
  * Serializes a given data object into string
165
218
  *
166
- * @param {unknown} data
167
- * @returns {string}
219
+ * @param data -
168
220
  */
169
221
  private readonly pack;
170
222
  /**
171
223
  * Deserialize string data into an object
172
224
  *
173
- * @param {string} data
174
- * @returns {unknown}
225
+ * @param data -
175
226
  */
176
227
  private readonly unpack;
177
228
  /**
178
- * @param {string} name
179
- * @param {IMQOptions} [options]
180
- * @param {IMQMode} [mode]
229
+ * Creates a queue handle. No connection is opened here — call
230
+ * {@link RedisQueue.start}, or {@link RedisQueue.send}, which starts the
231
+ * queue implicitly.
232
+ *
233
+ * @param name - queue name; the underlying Redis list key becomes
234
+ * `<prefix>:<name>`
235
+ * @param options - partial options merged over {@link DEFAULT_IMQ_OPTIONS}
236
+ * @param mode - whether this handle produces, consumes, or both; defaults to
237
+ * {@link IMQMode.BOTH}
238
+ *
239
+ * @remarks
240
+ * The constructor performs no I/O. It resolves the effective options, selects
241
+ * the serializer pair from {@link IMQOptions.useGzip} once, and derives
242
+ * the `host:port` key under which the shared connections are stored — so
243
+ * changing `useGzip`, `host` or `port` on `options` afterwards has no effect.
244
+ */
245
+ constructor(
246
+ /**
247
+ * The queue name. The underlying redis list key is `<prefix>:<name>`, the
248
+ * same name is the default pub/sub channel used by
249
+ * {@link RedisQueue.publish}, and it is the `from` value carried by
250
+ * messages this queue sends.
251
+ *
252
+ * @remarks
253
+ * Assign it before {@link RedisQueue.start} — a running reader keeps
254
+ * consuming the key it was started with.
181
255
  */
182
- constructor(name: string, options?: Partial<IMQOptions>, mode?: IMQMode);
256
+ name: string, options?: Partial<IMQOptions>, mode?: IMQMode);
183
257
  private verbose;
184
258
  /**
185
259
  * Creates a subscription channel over redis and sets up channel
186
- * data read handler
260
+ * data read handler. The effective Redis channel is `<prefix>:<channel>`.
261
+ *
262
+ * @param channel - channel name within this queue's prefix namespace
263
+ * @param handler - invoked with the parsed payload of each published message
264
+ * @throws TypeError when no channel name is given, or when a different
265
+ * channel name is supplied while a subscription is already open — an
266
+ * instance supports exactly one channel until
267
+ * {@link RedisQueue.unsubscribe} resets it
268
+ *
269
+ * @remarks
270
+ * Calling this again with the same channel adds another handler rather than
271
+ * replacing the existing one, and every handler is invoked for each message.
187
272
  *
188
- * @param {string} channel
189
- * @param {(data: JsonObject) => void} handler
190
- * @returns {Promise<void>}
273
+ * A dedicated subscription connection is created on demand, so
274
+ * {@link RedisQueue.start} is not required, and the subscription is
275
+ * re-established automatically after a reconnect.
276
+ *
277
+ * Payloads are parsed as plain JSON ({@link IMQOptions.useGzip} does not
278
+ * apply to pub/sub). Neither a parse error nor an exception thrown by the
279
+ * handler is contained by the queue, so handlers should not throw.
191
280
  */
192
281
  subscribe(channel: string, handler: (data: JsonObject) => void): Promise<void>;
193
282
  /**
194
283
  * Attaches a subscription message handler to a given channel
195
284
  * connection
196
285
  *
197
- * @param {IRedisClient} chan
198
- * @param {(data: JsonObject) => void} handler
286
+ * @param chan -
287
+ * @param handler -
199
288
  */
200
289
  private attachSubscriptionHandler;
201
290
  /**
202
291
  * Restores the subscription state on a freshly created subscription
203
292
  * connection. Used after a connection replacement on reconnection,
204
293
  * otherwise the new connection would silently stay unsubscribed.
205
- *
206
- * @returns {Promise<void>}
207
294
  */
208
295
  private restoreSubscription;
209
296
  /**
210
- * Closes subscription channel
297
+ * Closes the subscription connection and forgets the channel name together
298
+ * with every handler registered through {@link RedisQueue.subscribe}.
211
299
  *
212
- * @returns {Promise<void>}
300
+ * @remarks
301
+ * A later {@link RedisQueue.subscribe} must register its handlers again, and
302
+ * may use a different channel name. A no-op when the queue was never
303
+ * subscribed, and it never rejects — failures during unsubscribe are logged
304
+ * only. Called automatically by {@link RedisQueue.destroy}.
213
305
  */
214
306
  unsubscribe(): Promise<void>;
215
307
  /**
@@ -220,14 +312,42 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
220
312
  * can be used to implement broadcasting some messages to other subscribers
221
313
  * on other PubSub channels.
222
314
  *
223
- * @param {string} [toName]
224
- * @param {JsonObject} data
315
+ * @param data - payload to publish as a channel message
316
+ * @param toName - optional different pub/sub name to publish to; must be a
317
+ * bare name inside the same prefix namespace, not a full Redis channel
318
+ * key
319
+ * @throws TypeError when the queue has no writer connection
320
+ *
321
+ * @remarks
322
+ * Unlike {@link RedisQueue.send}, this does not start the queue
323
+ * implicitly, so {@link RedisQueue.start} must have completed first. It is
324
+ * allowed in any {@link IMQMode}, including `WORKER`.
325
+ *
326
+ * The payload is always plain JSON — {@link IMQOptions.useGzip} applies to
327
+ * queue messages only. Redis pub/sub drops the message silently when nobody
328
+ * is subscribed.
225
329
  */
226
330
  publish(data: JsonObject, toName?: string): Promise<void>;
227
331
  /**
228
- * Initializes and starts current queue routines
332
+ * Initializes and starts current queue routines: opens the writer (and, in
333
+ * {@link IMQMode.BOTH} or {@link IMQMode.WORKER} mode, the reader), joins
334
+ * watcher election and starts the periodic watcher check.
335
+ *
336
+ * @returns this queue instance
337
+ * @throws TypeError when the queue was constructed without a name
338
+ *
339
+ * @remarks
340
+ * Idempotent — a second call on a started queue resolves immediately — and
341
+ * the queue can be restarted after {@link RedisQueue.stop}.
342
+ *
343
+ * Unless {@link IMQOptions.handleSignals} is false, this installs
344
+ * process-level SIGTERM/SIGINT/SIGABRT handlers that release watcher locks
345
+ * and then exit the process without waiting for in-flight handlers.
229
346
  *
230
- * @returns {Promise<RedisQueue>}
347
+ * If watcher initialization fails the returned promise rejects, but the
348
+ * writer connection, the instance registration and any acquired watcher lock
349
+ * remain in place — call {@link RedisQueue.destroy} to clean up after a
350
+ * failed start.
231
351
  */
232
352
  start(): Promise<RedisQueue>;
233
353
  /**
@@ -238,8 +358,6 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
238
358
  /**
239
359
  * Frees watcher locks held by all started queue instances and exits
240
360
  * the process, forcing exit after IMQ_SHUTDOWN_TIMEOUT at the latest.
241
- *
242
- * @returns {Promise<void>}
243
361
  */
244
362
  private static freeAndExit;
245
363
  /**
@@ -253,8 +371,6 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
253
371
  * A single watcher-existence check tick: re-elects a watcher owner when
254
372
  * none exists and moves due to delayed messages as a keyspace-notification
255
373
  * fallback. Errors are contained so the interval never crashes.
256
- *
257
- * @returns {Promise<void>}
258
374
  */
259
375
  private runWatcherCheck;
260
376
  /**
@@ -262,19 +378,52 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
262
378
  */
263
379
  private stopWatcherCheck;
264
380
  /**
265
- * Sends a given message to a given queue (by name)
266
- *
267
- * @param {string} toQueue
268
- * @param {JsonObject} message
269
- * @param {number} [delay]
270
- * @param {(err: Error) => void} [errorHandler]
271
- * @returns {Promise<RedisQueue>}
381
+ * Sends a given message to a given queue (by name).
382
+ *
383
+ * @param toQueue - name of the destination queue
384
+ * @param message - message payload; must be a JSON object
385
+ * @param delay - if specified, the message becomes available in the target
386
+ * queue only after this many milliseconds. This is a minimum, not a
387
+ * schedule — the message is released by the watcher, so availability
388
+ * may lag by up to {@link IMQOptions.watcherCheckDelay}. A delay of
389
+ * `0` or `undefined` sends immediately.
390
+ * @param errorHandler - invoked when the write to Redis fails; this is the
391
+ * only way to observe such a failure, since the returned promise does
392
+ * not reject for it
393
+ * @returns the identifier assigned to the message. It is generated locally
394
+ * before the write is issued, so it is available even if the write
395
+ * later fails.
396
+ * @throws TypeError when the queue is in {@link IMQMode.WORKER}-only mode, or
397
+ * when a writer connection cannot be established
398
+ *
399
+ * @remarks
400
+ * The returned promise resolves as soon as the write has been dispatched —
401
+ * the Redis reply is not awaited — so a resolved promise is not evidence that
402
+ * the message was enqueued.
403
+ *
404
+ * Starts the queue implicitly when it has not been started yet, which has
405
+ * process-wide side effects: it may install signal handlers and make this
406
+ * instance the watcher owner.
272
407
  */
273
408
  send(toQueue: string, message: JsonObject, delay?: number, errorHandler?: (err: Error) => void): Promise<string>;
274
409
  /**
275
- * Stops current queue routines
410
+ * Stops consuming messages by tearing down this instance's reader
411
+ * connection.
412
+ *
413
+ * @returns this queue instance
414
+ *
415
+ * @remarks
416
+ * The queue remains usable as a producer: the shared writer, any held watcher
417
+ * lock, the watcher-check and maintenance intervals, the subscription
418
+ * connection and the process signal handlers all stay in place, and
419
+ * {@link RedisQueue.start} can resume consumption. Use
420
+ * {@link RedisQueue.destroy} to release resources — an instance that is only
421
+ * stopped stays registered in a process-wide registry and is not
422
+ * garbage-collected.
276
423
  *
277
- * @returns {Promise<RedisQueue>}
424
+ * The reader socket is dropped immediately rather than closed with a graceful
425
+ * `QUIT`, so Redis stops treating it as a consumer at once and cannot hand it
426
+ * a message the torn-down read loop would drop.
278
427
  */
279
428
  stop(): Promise<RedisQueue>;
280
429
  /**
@@ -283,98 +432,109 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
283
432
  * destroying one handle (e.g., on scale-down) never wipes messages
284
433
  * still pending for other producers/consumers.
285
434
  *
286
- * @param {boolean} [clearData] - when true, also clears queue data
287
- * @returns {Promise<void>}
435
+ * @param clearData - when true, also clears queue data
436
+ *
437
+ * @remarks
438
+ * The writer connection is shared per `host:port` and reference-counted, so
439
+ * it stays open while another started instance in the process still uses it.
440
+ *
441
+ * All event listeners are removed, including the caller's `message` and
442
+ * `error` handlers — and because {@link RedisQueue.start} can revive the
443
+ * instance, re-register them if you restart it or messages will be consumed
444
+ * and silently discarded.
445
+ *
446
+ * With `clearData` set, only the main and delayed keys are removed: messages
447
+ * currently leased to a worker key under {@link IMQOptions.safeDelivery} are
448
+ * not, and the watcher will re-queue them once their lease expires — so
449
+ * messages can reappear after a clearing destroy.
450
+ *
451
+ * Never rejects; unlock and clear failures are logged.
288
452
  */
289
453
  destroy(clearData?: boolean): Promise<void>;
290
454
  /**
291
- * Clears queue data in redis
455
+ * Deletes this queue's message list and its delayed-message set from redis.
456
+ *
457
+ * @returns this queue instance
292
458
  *
293
- * @returns {Promise<void>}
459
+ * @remarks
460
+ * A no-op that resolves successfully when the queue has no writer connection.
461
+ * In-flight messages held in worker keys under
462
+ * {@link IMQOptions.safeDelivery} are not removed and may be re-queued by the
463
+ * watcher after their lease expires, so this does not guarantee the queue
464
+ * stays empty. Errors are logged rather than thrown, so success cannot be
465
+ * inferred from a resolved promise.
294
466
  */
295
467
  clear(): Promise<RedisQueue>;
296
468
  /**
297
- * Retrieves the current count of messages in the queue
469
+ * Returns the number of messages currently waiting in this queue's main list.
298
470
  *
299
- * @returns {Promise<number>}
471
+ * @returns count of messages waiting to be consumed
472
+ *
473
+ * @remarks
474
+ * Delayed messages that are not yet due, and messages currently leased to a
475
+ * worker under {@link IMQOptions.safeDelivery}, are not counted — so this
476
+ * is not the amount of outstanding work. Returns `0` when the queue has no
477
+ * writer connection, which makes "disconnected" indistinguishable from
478
+ * "empty"; it never throws.
300
479
  */
301
480
  queueLength(): Promise<number>;
302
481
  /**
303
482
  * Returns true if publisher mode is enabled on this queue, false otherwise.
304
- *
305
- * @returns {boolean}
306
483
  */
307
484
  isPublisher(): boolean;
308
485
  /**
309
486
  * Returns true if worker mode is enabled on this queue, false otherwise.
310
- *
311
- * @returns {boolean}
312
487
  */
313
488
  isWorker(): boolean;
314
489
  /**
315
490
  * Returns false only when this queue is known to be unable to accept
316
491
  * writes right now — i.e., it has a writer connection currently
317
492
  * in a non-ready (reconnecting/closed) state. A queue that has not yet
318
- * connected is considered available, since a sending lazily connects it.
493
+ * connected is considered available, since sending connects it lazily.
319
494
  * Used for health-aware routing in the clustered queue.
320
495
  *
321
- * @returns {boolean}
496
+ * @remarks
497
+ * The writer connection is shared per `host:port` within the process, so this
498
+ * reflects the health of that server connection rather than of this instance
499
+ * alone — every queue pointing at the same server reports the same value.
322
500
  */
323
501
  get available(): boolean;
324
502
  /**
325
- * Writer connection associated with this queue instance
326
- *
327
- * @type {IRedisClient}
503
+ * Writer connection associated with this queue instance. Shared by every
504
+ * queue in the process that targets the same `host:port`.
328
505
  */
329
506
  private get writer();
330
- /**
331
- * Writer connection setter.
332
- *
333
- * @param {IRedisClient} conn
334
- */
335
507
  private set writer(value);
336
508
  /**
337
- * Watcher connection instance associated with this queue instance
338
- *
339
- * @type {IRedisClient}
509
+ * Watcher connection associated with this queue instance. Shared by every
510
+ * queue in the process that targets the same `host:port`; at most one queue
511
+ * per prefix is the elected watcher owner.
340
512
  */
341
513
  private get watcher();
342
- /**
343
- * Watcher setter sets the watcher connection property for this
344
- * queue instance
345
- *
346
- * @param {IRedisClient} conn
347
- */
348
514
  private set watcher(value);
349
515
  /**
350
516
  * Returns the connection currently bound to the given channel, if any.
351
517
  *
352
- * @param {RedisConnectionChannel} channel
353
- * @returns {IRedisClient | undefined}
518
+ * @param channel -
354
519
  */
355
520
  private connectionOf;
356
521
  /**
357
522
  * Binds the given connection to the given channel.
358
523
  *
359
- * @param {RedisConnectionChannel} channel
360
- * @param {IRedisClient} conn
524
+ * @param channel -
525
+ * @param conn -
361
526
  */
362
527
  private bindConnection;
363
528
  /**
364
529
  * Logger instance associated with the current queue instance
365
- * @type {ILogger}
366
530
  */
367
531
  private get logger();
368
532
  /**
369
533
  * Return a lock key for watcher connection
370
- *
371
- * @returns {string}
372
534
  */
373
535
  private get lockKey();
374
536
  /**
375
537
  * Returns current queue key
376
- *
377
- * @returns {string}
378
538
  */
379
539
  private get key();
380
540
  /**
@@ -392,17 +552,15 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
392
552
  /**
393
553
  * Establishes a given connection channel by its name
394
554
  *
395
- * @param {RedisConnectionChannel} channel
396
- * @param {IMQOptions} options
397
- * @returns {Promise<IRedisClient>}
555
+ * @param channel -
556
+ * @param options -
398
557
  */
399
558
  private connect;
400
559
  /**
401
560
  * Schedules custom reconnection for a given channel with capped
402
561
  * exponential backoff
403
562
  *
404
- * @param {RedisConnectionChannel} channel
405
- * @private
563
+ * @param channel -
406
564
  */
407
565
  private scheduleReconnect;
408
566
  /**
@@ -410,72 +568,60 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
410
568
  * rescheduling itself on failure. Errors are handled internally, so the
411
569
  * scheduled timer never produces an unhandled rejection.
412
570
  *
413
- * @param {RedisConnectionChannel} channel
414
- * @returns {Promise<void>}
571
+ * @param channel -
415
572
  */
416
573
  private reconnectNow;
417
574
  /**
418
575
  * Generates channel name
419
576
  *
420
- * @param {string} contextName
421
- * @param {string} prefix
422
- * @param {RedisConnectionChannel} name
423
- * @returns {string}
577
+ * @param contextName -
578
+ * @param prefix -
579
+ * @param name -
424
580
  */
425
581
  private getChannelName;
426
582
  /**
427
583
  * Builds and returns connection error handler
428
584
  *
429
- * @param {RedisConnectionChannel} channel
430
- * @returns {(err: Error) => void}
585
+ * @param channel -
431
586
  */
432
587
  private onErrorHandler;
433
588
  /**
434
589
  * Builds and returns redis connection close handler
435
590
  *
436
- * @param {RedisConnectionChannel} channel
437
- * @returns {() => void}
591
+ * @param channel -
438
592
  */
439
593
  private onCloseHandler;
440
594
  /**
441
595
  * Processes given redis-queue message
442
596
  *
443
- * @param {[string, string]} msg
444
- * @returns {RedisQueue}
597
+ * @param msg -
445
598
  */
446
599
  private process;
447
600
  /**
448
601
  * Returns the number of established watcher connections on redis
449
- *
450
- * @returns {Promise<number>}
451
602
  */
452
603
  private watcherCount;
453
604
  /**
454
605
  * Processes delayed a message by its given redis key
455
606
  *
456
- * @param {string} key
457
- * @returns {Promise<void>}
607
+ * @param key -
458
608
  */
459
609
  private processDelayed;
460
610
  /**
461
611
  * Watch routine
462
- *
463
- * @returns {Promise<void>}
464
612
  */
465
613
  private processWatch;
466
614
  /**
467
615
  * Process given keys from a message queue
468
616
  *
469
- * @param {string[]} keys
470
- * @param {number} now
471
- * @returns {Promise<void>}
617
+ * @param keys -
618
+ * @param now -
472
619
  */
473
620
  private processKeys;
474
621
  /**
475
622
  * Watch message processor
476
623
  *
477
- * @param {...any[]} args
478
- * @returns {Promise<void>}
624
+ * @param args -
479
625
  */
480
626
  private onWatchMessage;
481
627
  /**
@@ -484,21 +630,15 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
484
630
  private cleanSafeCheckInterval;
485
631
  /**
486
632
  * Setups watch a process on delayed messages
487
- *
488
- * @returns {RedisQueue}
489
633
  */
490
634
  private watch;
491
635
  /**
492
636
  * A single safe-delivery maintenance tick: recovers messages from dead
493
637
  * workers (when safe delivery is on) and prunes orphaned keys.
494
- *
495
- * @returns {Promise<void>}
496
638
  */
497
639
  private runSafeCheck;
498
640
  /**
499
641
  * Cleans up orphaned keys from redis
500
- *
501
- * @returns {Promise<RedisQueue | undefined>}
502
642
  */
503
643
  private processCleanup;
504
644
  /**
@@ -516,55 +656,41 @@ export declare class RedisQueue extends EventEmitter<EventMap> implements IMessa
516
656
  private readSafe;
517
657
  /**
518
658
  * Initializes a read process on the redis message queue
519
- *
520
- * @returns {RedisQueue}
521
659
  */
522
660
  private read;
523
661
  /**
524
662
  * Checks if the watcher connection is locked
525
- *
526
- * @returns {Promise<boolean>}
527
663
  */
528
664
  private isLocked;
529
665
  /**
530
666
  * Locks watcher connection
531
- *
532
- * @returns {Promise<boolean>}
533
667
  */
534
668
  private lock;
535
669
  /**
536
670
  * Unlocks watcher connection
537
- *
538
- * @returns {Promise<boolean>}
539
671
  */
540
672
  private unlock;
541
673
  /**
542
674
  * Emits error
543
675
  *
544
- * @param {string} eventName
545
- * @param {string} message
546
- * @param {unknown} err
676
+ * @param eventName -
677
+ * @param message -
678
+ * @param err -
547
679
  */
548
680
  private emitError;
549
681
  /**
550
682
  * Acquires an owner for watcher connection to this instance of the queue
551
- *
552
- * @returns {Promise<void>}
553
683
  */
554
684
  private ownWatch;
555
685
  /**
556
686
  * Attempts to take over an orphaned watcher lock: if the lock is held
557
687
  * but no watcher connection is actually alive, releases and re-acquires
558
688
  * ownership. Used to resolve a possible watcher deadlock.
559
- *
560
- * @returns {Promise<void>}
561
689
  */
562
690
  private resolveWatchLock;
563
691
  /**
564
692
  * Initializes a single watcher connection across all queues with the same
565
693
  * prefix.
566
- *
567
- * @returns {Promise<void>}
568
694
  */
569
695
  private initWatcher;
570
696
  }