redis-smq 8.0.0-rc.13 → 8.0.0-rc.14
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/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/dist/index.cjs +16 -13
- package/dist/index.d.cts +52 -56
- package/dist/index.d.ts +52 -56
- package/dist/index.js +16 -13
- package/dist/lua/delete-message.lua +34 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [8.0.0-rc.14](https://github.com/weyoss/redis-smq/compare/v8.0.0-rc.13...v8.0.0-rc.14) (2024-01-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Documentation
|
|
7
|
+
|
|
8
|
+
* add new diagrams and update existing ones ([f5182b1](https://github.com/weyoss/redis-smq/commit/f5182b10b5179365edf68e7b6bf564ccc25281ab))
|
|
9
|
+
* **event-listeners:** add a link to IRedisSMQConfig interface ([a7635c5](https://github.com/weyoss/redis-smq/commit/a7635c5d811ad775123547a5696c78b030981269))
|
|
10
|
+
* scale down diagrams ([c3b37e4](https://github.com/weyoss/redis-smq/commit/c3b37e445a6d15fdcc8c7a73b713a1f7d5e7c94e))
|
|
11
|
+
* update exchange diagrams ([9dc05d6](https://github.com/weyoss/redis-smq/commit/9dc05d6cd835d779b9d183e83f562c7991105c92))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Codebase Refactoring
|
|
15
|
+
|
|
16
|
+
* **event-listeners:** clean up ([d9195e4](https://github.com/weyoss/redis-smq/commit/d9195e4e85e2e4519d238f5f3ecace37ae9bbb32))
|
|
17
|
+
* **exchanges:** improve typings ([97665fe](https://github.com/weyoss/redis-smq/commit/97665fed4a579af444c46e01a6b05f9adb12e888))
|
|
18
|
+
* **message:** handle various errors when deleting a message ([a4505ae](https://github.com/weyoss/redis-smq/commit/a4505ae7d95bda0185da28433c6737e395400e7b))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Tests
|
|
22
|
+
|
|
23
|
+
* **message:** handle various errors when deleting a message ([ecf301b](https://github.com/weyoss/redis-smq/commit/ecf301b06aac1bf6d0fcb1ced962a32ac6a6ca68))
|
|
24
|
+
|
|
3
25
|
## [8.0.0-rc.13](https://github.com/weyoss/redis-smq/compare/v8.0.0-rc.12...v8.0.0-rc.13) (2023-12-23)
|
|
4
26
|
|
|
5
27
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center" style="text-align: center">
|
|
2
2
|
<p><a href="https://github.com/weyoss/redis-smq"><img alt="RedisSMQ" src="./logo.png?v=202312182134" /></a></p>
|
|
3
|
-
<p>A simple high-performance Redis message queue for Node.js.</p>
|
|
3
|
+
<p style='color: #d82c20'>A simple high-performance Redis message queue for Node.js.</p>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
# RedisSMQ
|
|
@@ -35,7 +35,7 @@ RedisSMQ is a Node.js library for queuing messages (aka jobs) and processing the
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-

|
|
39
39
|
|
|
40
40
|
## What's new?
|
|
41
41
|
|
package/dist/index.cjs
CHANGED
|
@@ -420,7 +420,7 @@ var EConsumeMessageUnacknowledgedCause = /* @__PURE__ */ ((EConsumeMessageUnackn
|
|
|
420
420
|
return EConsumeMessageUnacknowledgedCause3;
|
|
421
421
|
})(EConsumeMessageUnacknowledgedCause || {});
|
|
422
422
|
|
|
423
|
-
// types/exchange/
|
|
423
|
+
// types/exchange/common.ts
|
|
424
424
|
var EExchangeType = /* @__PURE__ */ ((EExchangeType2) => {
|
|
425
425
|
EExchangeType2[EExchangeType2["DIRECT"] = 0] = "DIRECT";
|
|
426
426
|
EExchangeType2[EExchangeType2["FANOUT"] = 1] = "FANOUT";
|
|
@@ -855,6 +855,9 @@ var Base = class extends import_redis_smq_common11.EventEmitter {
|
|
|
855
855
|
cb
|
|
856
856
|
);
|
|
857
857
|
}
|
|
858
|
+
hasEventListeners() {
|
|
859
|
+
return !!Configuration.getSetConfig().eventListeners.length;
|
|
860
|
+
}
|
|
858
861
|
handleError(err) {
|
|
859
862
|
if (this.powerSwitch.isGoingUp() || this.powerSwitch.isRunning()) {
|
|
860
863
|
throw err;
|
|
@@ -3962,24 +3965,23 @@ var Consumer = class extends Base {
|
|
|
3962
3965
|
}
|
|
3963
3966
|
registerSystemEventListeners() {
|
|
3964
3967
|
super.registerSystemEventListeners();
|
|
3965
|
-
this.
|
|
3966
|
-
|
|
3968
|
+
if (this.hasEventListeners()) {
|
|
3969
|
+
this.on("messageAcknowledged", (...args) => {
|
|
3967
3970
|
this.eventListeners.forEach(
|
|
3968
3971
|
(i) => i.emit("messageAcknowledged", ...args)
|
|
3969
3972
|
);
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
if (this.eventListeners.length)
|
|
3973
|
+
});
|
|
3974
|
+
this.on("messageUnacknowledged", (...args) => {
|
|
3973
3975
|
this.eventListeners.forEach(
|
|
3974
3976
|
(i) => i.emit("messageUnacknowledged", ...args)
|
|
3975
3977
|
);
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
if (this.eventListeners.length)
|
|
3978
|
+
});
|
|
3979
|
+
this.on("messageDeadLettered", (...args) => {
|
|
3979
3980
|
this.eventListeners.forEach(
|
|
3980
3981
|
(i) => i.emit("messageDeadLettered", ...args)
|
|
3981
3982
|
);
|
|
3982
|
-
|
|
3983
|
+
});
|
|
3984
|
+
}
|
|
3983
3985
|
}
|
|
3984
3986
|
goingUp() {
|
|
3985
3987
|
return super.goingUp().concat([
|
|
@@ -4071,10 +4073,11 @@ function _scheduleMessage(mixed, message, cb) {
|
|
|
4071
4073
|
var Producer = class extends Base {
|
|
4072
4074
|
registerSystemEventListeners() {
|
|
4073
4075
|
super.registerSystemEventListeners();
|
|
4074
|
-
this.
|
|
4075
|
-
|
|
4076
|
+
if (this.hasEventListeners()) {
|
|
4077
|
+
this.on("messagePublished", (...args) => {
|
|
4076
4078
|
this.eventListeners.forEach((i) => i.emit("messagePublished", ...args));
|
|
4077
|
-
|
|
4079
|
+
});
|
|
4080
|
+
}
|
|
4078
4081
|
}
|
|
4079
4082
|
enqueue(redisClient2, queue, message, cb) {
|
|
4080
4083
|
var _a;
|
package/dist/index.d.cts
CHANGED
|
@@ -403,36 +403,68 @@ interface IEventListener extends EventEmitter<TRedisSMQEvent> {
|
|
|
403
403
|
|
|
404
404
|
type TEventListenersConfig = (new () => IEventListener)[];
|
|
405
405
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
declare abstract class Exchange<TBindingParams, ExchangeType extends EExchangeType> implements IExchange<TBindingParams, ExchangeType> {
|
|
407
|
+
readonly type: ExchangeType;
|
|
408
|
+
readonly bindingParams: TBindingParams;
|
|
409
|
+
exchangeTag: string;
|
|
410
|
+
protected constructor(bindingParams: TBindingParams, type: ExchangeType);
|
|
411
|
+
protected generateExchangeTag(): string;
|
|
412
|
+
getBindingParams(): TBindingParams;
|
|
413
|
+
toJSON(): IExchangeSerialized<TBindingParams, ExchangeType>;
|
|
414
|
+
fromJSON(JSON: Partial<IExchangeSerialized<TBindingParams, ExchangeType>>): void;
|
|
415
|
+
protected abstract validateBindingParams(bindingParams: TBindingParams): TBindingParams;
|
|
416
|
+
abstract getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
declare class ExchangeDirect extends Exchange<TExchangeDirectBindingParams, EExchangeType.DIRECT> {
|
|
420
|
+
constructor(queue: TExchangeDirectBindingParams);
|
|
421
|
+
protected validateBindingParams(queue: TExchangeDirectBindingParams): IQueueParams;
|
|
422
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
declare class ExchangeTopic extends Exchange<TExchangeTopicBindingParams, EExchangeType.TOPIC> {
|
|
426
|
+
constructor(topic: TExchangeTopicBindingParams);
|
|
427
|
+
protected validateBindingParams(topicParams: TExchangeTopicBindingParams): TTopicParams;
|
|
428
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
declare class ExchangeFanOut extends Exchange<TExchangeFanOutBindingParams, EExchangeType.FANOUT> {
|
|
432
|
+
constructor(fanOutName: TExchangeFanOutBindingParams);
|
|
433
|
+
protected validateBindingParams(bindingParams: TExchangeFanOutBindingParams): string;
|
|
434
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
435
|
+
saveExchange(cb: ICallback<void>): void;
|
|
436
|
+
deleteExchange(cb: ICallback<void>): void;
|
|
437
|
+
bindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
438
|
+
unbindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
439
|
+
static getAllExchanges(cb: ICallback<string[]>): void;
|
|
440
|
+
static getQueueExchange(queue: IQueueParams | string, cb: ICallback<ExchangeFanOut | null>): void;
|
|
441
|
+
}
|
|
442
|
+
|
|
410
443
|
declare enum EExchangeType {
|
|
411
444
|
DIRECT = 0,
|
|
412
445
|
FANOUT = 1,
|
|
413
446
|
TOPIC = 2
|
|
414
447
|
}
|
|
448
|
+
type TTopicParams = {
|
|
449
|
+
topic: string;
|
|
450
|
+
ns: string;
|
|
451
|
+
};
|
|
415
452
|
type TExchangeDirectBindingParams = IQueueParams | string;
|
|
416
|
-
type TExchangeFanOutBindingParams = string;
|
|
417
453
|
type TExchangeTopicBindingParams = TTopicParams | string;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
454
|
+
type TExchangeFanOutBindingParams = string;
|
|
455
|
+
type TExchange = ExchangeDirect | ExchangeTopic | ExchangeFanOut;
|
|
456
|
+
type TExchangeSerialized = ReturnType<ExchangeDirect['toJSON']> | ReturnType<ExchangeTopic['toJSON']> | ReturnType<ExchangeFanOut['toJSON']>;
|
|
457
|
+
|
|
423
458
|
interface IExchangeSerialized<BindingParams, ExchangeType extends EExchangeType> {
|
|
424
459
|
readonly type: ExchangeType;
|
|
425
460
|
readonly bindingParams: BindingParams;
|
|
426
461
|
readonly exchangeTag: string;
|
|
427
462
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
type TExchangeFanOut = IExchange<TExchangeFanOutBindingParams, EExchangeType.FANOUT>;
|
|
434
|
-
type TExchange = TExchangeDirect | TExchangeTopic | TExchangeFanOut;
|
|
435
|
-
type TExchangeSerialized = TExchangeDirectSerialized | TExchangeTopicSerialized | TExchangeFanOutSerialized;
|
|
463
|
+
interface IExchange<BindingParams, ExchangeType extends EExchangeType> extends IExchangeSerialized<BindingParams, ExchangeType> {
|
|
464
|
+
toJSON(): IExchangeSerialized<BindingParams, ExchangeType>;
|
|
465
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
466
|
+
getBindingParams(): BindingParams;
|
|
467
|
+
}
|
|
436
468
|
|
|
437
469
|
interface IQueueMessages {
|
|
438
470
|
countMessages(queue: string | IQueueParams, cb: ICallback<number>): void;
|
|
@@ -587,6 +619,7 @@ declare abstract class Base extends EventEmitter<TRedisSMQEvent> {
|
|
|
587
619
|
protected getSharedRedisClient(): RedisClient;
|
|
588
620
|
protected registerEventListeners(Ctors: (new () => IEventListener)[], cb: ICallback<void>): void;
|
|
589
621
|
protected tearDownEventListeners: (cb: ICallback<void>) => void;
|
|
622
|
+
protected hasEventListeners(): boolean;
|
|
590
623
|
handleError(err: Error): void;
|
|
591
624
|
run(cb?: ICallback<boolean>): void;
|
|
592
625
|
shutdown(cb?: ICallback<boolean>): void;
|
|
@@ -718,43 +751,6 @@ declare class Message {
|
|
|
718
751
|
deleteMessageById(id: string, cb: ICallback<void>): void;
|
|
719
752
|
}
|
|
720
753
|
|
|
721
|
-
declare abstract class Exchange<TBindingParams, ExchangeType extends EExchangeType> implements IExchange<TBindingParams, ExchangeType> {
|
|
722
|
-
readonly type: ExchangeType;
|
|
723
|
-
readonly bindingParams: TBindingParams;
|
|
724
|
-
exchangeTag: string;
|
|
725
|
-
protected constructor(bindingParams: TBindingParams, type: ExchangeType);
|
|
726
|
-
protected generateExchangeTag(): string;
|
|
727
|
-
getBindingParams(): TBindingParams;
|
|
728
|
-
toJSON(): IExchangeSerialized<TBindingParams, ExchangeType>;
|
|
729
|
-
fromJSON(JSON: Partial<IExchangeSerialized<TBindingParams, ExchangeType>>): void;
|
|
730
|
-
protected abstract validateBindingParams(bindingParams: TBindingParams): TBindingParams;
|
|
731
|
-
abstract getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
declare class ExchangeDirect extends Exchange<TExchangeDirectBindingParams, EExchangeType.DIRECT> {
|
|
735
|
-
constructor(queue: TExchangeDirectBindingParams);
|
|
736
|
-
protected validateBindingParams(queue: TExchangeDirectBindingParams): IQueueParams;
|
|
737
|
-
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
declare class ExchangeTopic extends Exchange<TExchangeTopicBindingParams, EExchangeType.TOPIC> {
|
|
741
|
-
constructor(topic: TExchangeTopicBindingParams);
|
|
742
|
-
protected validateBindingParams(topicParams: TExchangeTopicBindingParams): TTopicParams;
|
|
743
|
-
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
declare class ExchangeFanOut extends Exchange<TExchangeFanOutBindingParams, EExchangeType.FANOUT> {
|
|
747
|
-
constructor(fanOutName: TExchangeFanOutBindingParams);
|
|
748
|
-
protected validateBindingParams(bindingParams: TExchangeFanOutBindingParams): string;
|
|
749
|
-
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
750
|
-
saveExchange(cb: ICallback<void>): void;
|
|
751
|
-
deleteExchange(cb: ICallback<void>): void;
|
|
752
|
-
bindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
753
|
-
unbindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
754
|
-
static getAllExchanges(cb: ICallback<string[]>): void;
|
|
755
|
-
static getQueueExchange(queue: IQueueParams | string, cb: ICallback<ExchangeFanOut | null>): void;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
754
|
declare class Namespace {
|
|
759
755
|
getNamespaces(cb: ICallback<string[]>): void;
|
|
760
756
|
getNamespaceQueues(namespace: string, cb: ICallback<IQueueParams[]>): void;
|
|
@@ -855,4 +851,4 @@ declare class Configuration {
|
|
|
855
851
|
|
|
856
852
|
declare function disconnect(cb: ICallback<void>): void;
|
|
857
853
|
|
|
858
|
-
export { Configuration, Consumer, ConsumerError, ConsumerMessageHandlerAlreadyExistsError, EConsumeMessageDeadLetterCause, EConsumeMessageUnacknowledgedCause, EExchangeType, EMessagePriority, EMessageProperty, EMessagePropertyStatus, EQueueProperty, EQueueType, ExchangeDirect, ExchangeError, ExchangeFanOut, ExchangeFanOutError, ExchangeInvalidDataError, ExchangeTopic, type IConsumableMessage, type IConsumerHeartbeat, type IConsumerHeartbeatPayload, type IConsumerMessageHandlerArgs, type IEventListener, type IExchange, type IExchangeSerialized, type IMessageSerialized, type IMessageStateSerialized, type IMessagesConfig, type IMessagesConfigStorage, type IMessagesConfigStorageOptions, type IMessagesConfigStorageOptionsRequired, type IMessagesConfigStorageRequired, type IQueueMessages, type IQueueMessagesCount, type IQueueMessagesPage, type IQueueMessagesPageParams, type IQueueParams, type IQueueProperties, type IQueueRateLimit, type IRedisSMQConfig, type IRedisSMQConfigRequired, Message, MessageDeleteError, MessageDestinationQueueAlreadySetError, MessageDestinationQueueRequiredError, MessageError, MessageExchangeRequiredError, MessageNotFoundError, Namespace, Producer, ProducerError, ProducerInstanceNotRunningError, ProducerMessageNotPublishedError, ProducerMessageNotScheduledError, ProducibleMessage, Queue, QueueAcknowledgedMessages, QueueDeadLetteredMessages, QueueError, QueueExistsError, QueueHasRunningConsumersError, QueueMessageRequeueError, QueueMessages, QueueNamespaceNotFoundError, QueueNotEmptyError, QueueNotFoundError, QueuePendingMessages, QueueRateLimit, QueueRateLimitError, QueueScheduledMessages, type TConsumerMessageHandler, type TConsumerRedisKeys, type TEventListenersConfig, type TExchange, type
|
|
854
|
+
export { Configuration, Consumer, ConsumerError, ConsumerMessageHandlerAlreadyExistsError, EConsumeMessageDeadLetterCause, EConsumeMessageUnacknowledgedCause, EExchangeType, EMessagePriority, EMessageProperty, EMessagePropertyStatus, EQueueProperty, EQueueType, ExchangeDirect, ExchangeError, ExchangeFanOut, ExchangeFanOutError, ExchangeInvalidDataError, ExchangeTopic, type IConsumableMessage, type IConsumerHeartbeat, type IConsumerHeartbeatPayload, type IConsumerMessageHandlerArgs, type IEventListener, type IExchange, type IExchangeSerialized, type IMessageSerialized, type IMessageStateSerialized, type IMessagesConfig, type IMessagesConfigStorage, type IMessagesConfigStorageOptions, type IMessagesConfigStorageOptionsRequired, type IMessagesConfigStorageRequired, type IQueueMessages, type IQueueMessagesCount, type IQueueMessagesPage, type IQueueMessagesPageParams, type IQueueParams, type IQueueProperties, type IQueueRateLimit, type IRedisSMQConfig, type IRedisSMQConfigRequired, Message, MessageDeleteError, MessageDestinationQueueAlreadySetError, MessageDestinationQueueRequiredError, MessageError, MessageExchangeRequiredError, MessageNotFoundError, Namespace, Producer, ProducerError, ProducerInstanceNotRunningError, ProducerMessageNotPublishedError, ProducerMessageNotScheduledError, ProducibleMessage, Queue, QueueAcknowledgedMessages, QueueDeadLetteredMessages, QueueError, QueueExistsError, QueueHasRunningConsumersError, QueueMessageRequeueError, QueueMessages, QueueNamespaceNotFoundError, QueueNotEmptyError, QueueNotFoundError, QueuePendingMessages, QueueRateLimit, QueueRateLimitError, QueueScheduledMessages, type TConsumerMessageHandler, type TConsumerRedisKeys, type TEventListenersConfig, type TExchange, type TExchangeDirectBindingParams, type TExchangeFanOutBindingParams, type TExchangeSerialized, type TExchangeTopicBindingParams, type TMessageConsumeOptions, type TQueueConsumer, type TRedisSMQEvent, type TTopicParams, disconnect };
|
package/dist/index.d.ts
CHANGED
|
@@ -403,36 +403,68 @@ interface IEventListener extends EventEmitter<TRedisSMQEvent> {
|
|
|
403
403
|
|
|
404
404
|
type TEventListenersConfig = (new () => IEventListener)[];
|
|
405
405
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
declare abstract class Exchange<TBindingParams, ExchangeType extends EExchangeType> implements IExchange<TBindingParams, ExchangeType> {
|
|
407
|
+
readonly type: ExchangeType;
|
|
408
|
+
readonly bindingParams: TBindingParams;
|
|
409
|
+
exchangeTag: string;
|
|
410
|
+
protected constructor(bindingParams: TBindingParams, type: ExchangeType);
|
|
411
|
+
protected generateExchangeTag(): string;
|
|
412
|
+
getBindingParams(): TBindingParams;
|
|
413
|
+
toJSON(): IExchangeSerialized<TBindingParams, ExchangeType>;
|
|
414
|
+
fromJSON(JSON: Partial<IExchangeSerialized<TBindingParams, ExchangeType>>): void;
|
|
415
|
+
protected abstract validateBindingParams(bindingParams: TBindingParams): TBindingParams;
|
|
416
|
+
abstract getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
declare class ExchangeDirect extends Exchange<TExchangeDirectBindingParams, EExchangeType.DIRECT> {
|
|
420
|
+
constructor(queue: TExchangeDirectBindingParams);
|
|
421
|
+
protected validateBindingParams(queue: TExchangeDirectBindingParams): IQueueParams;
|
|
422
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
declare class ExchangeTopic extends Exchange<TExchangeTopicBindingParams, EExchangeType.TOPIC> {
|
|
426
|
+
constructor(topic: TExchangeTopicBindingParams);
|
|
427
|
+
protected validateBindingParams(topicParams: TExchangeTopicBindingParams): TTopicParams;
|
|
428
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
declare class ExchangeFanOut extends Exchange<TExchangeFanOutBindingParams, EExchangeType.FANOUT> {
|
|
432
|
+
constructor(fanOutName: TExchangeFanOutBindingParams);
|
|
433
|
+
protected validateBindingParams(bindingParams: TExchangeFanOutBindingParams): string;
|
|
434
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
435
|
+
saveExchange(cb: ICallback<void>): void;
|
|
436
|
+
deleteExchange(cb: ICallback<void>): void;
|
|
437
|
+
bindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
438
|
+
unbindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
439
|
+
static getAllExchanges(cb: ICallback<string[]>): void;
|
|
440
|
+
static getQueueExchange(queue: IQueueParams | string, cb: ICallback<ExchangeFanOut | null>): void;
|
|
441
|
+
}
|
|
442
|
+
|
|
410
443
|
declare enum EExchangeType {
|
|
411
444
|
DIRECT = 0,
|
|
412
445
|
FANOUT = 1,
|
|
413
446
|
TOPIC = 2
|
|
414
447
|
}
|
|
448
|
+
type TTopicParams = {
|
|
449
|
+
topic: string;
|
|
450
|
+
ns: string;
|
|
451
|
+
};
|
|
415
452
|
type TExchangeDirectBindingParams = IQueueParams | string;
|
|
416
|
-
type TExchangeFanOutBindingParams = string;
|
|
417
453
|
type TExchangeTopicBindingParams = TTopicParams | string;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
454
|
+
type TExchangeFanOutBindingParams = string;
|
|
455
|
+
type TExchange = ExchangeDirect | ExchangeTopic | ExchangeFanOut;
|
|
456
|
+
type TExchangeSerialized = ReturnType<ExchangeDirect['toJSON']> | ReturnType<ExchangeTopic['toJSON']> | ReturnType<ExchangeFanOut['toJSON']>;
|
|
457
|
+
|
|
423
458
|
interface IExchangeSerialized<BindingParams, ExchangeType extends EExchangeType> {
|
|
424
459
|
readonly type: ExchangeType;
|
|
425
460
|
readonly bindingParams: BindingParams;
|
|
426
461
|
readonly exchangeTag: string;
|
|
427
462
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
type TExchangeFanOut = IExchange<TExchangeFanOutBindingParams, EExchangeType.FANOUT>;
|
|
434
|
-
type TExchange = TExchangeDirect | TExchangeTopic | TExchangeFanOut;
|
|
435
|
-
type TExchangeSerialized = TExchangeDirectSerialized | TExchangeTopicSerialized | TExchangeFanOutSerialized;
|
|
463
|
+
interface IExchange<BindingParams, ExchangeType extends EExchangeType> extends IExchangeSerialized<BindingParams, ExchangeType> {
|
|
464
|
+
toJSON(): IExchangeSerialized<BindingParams, ExchangeType>;
|
|
465
|
+
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
466
|
+
getBindingParams(): BindingParams;
|
|
467
|
+
}
|
|
436
468
|
|
|
437
469
|
interface IQueueMessages {
|
|
438
470
|
countMessages(queue: string | IQueueParams, cb: ICallback<number>): void;
|
|
@@ -587,6 +619,7 @@ declare abstract class Base extends EventEmitter<TRedisSMQEvent> {
|
|
|
587
619
|
protected getSharedRedisClient(): RedisClient;
|
|
588
620
|
protected registerEventListeners(Ctors: (new () => IEventListener)[], cb: ICallback<void>): void;
|
|
589
621
|
protected tearDownEventListeners: (cb: ICallback<void>) => void;
|
|
622
|
+
protected hasEventListeners(): boolean;
|
|
590
623
|
handleError(err: Error): void;
|
|
591
624
|
run(cb?: ICallback<boolean>): void;
|
|
592
625
|
shutdown(cb?: ICallback<boolean>): void;
|
|
@@ -718,43 +751,6 @@ declare class Message {
|
|
|
718
751
|
deleteMessageById(id: string, cb: ICallback<void>): void;
|
|
719
752
|
}
|
|
720
753
|
|
|
721
|
-
declare abstract class Exchange<TBindingParams, ExchangeType extends EExchangeType> implements IExchange<TBindingParams, ExchangeType> {
|
|
722
|
-
readonly type: ExchangeType;
|
|
723
|
-
readonly bindingParams: TBindingParams;
|
|
724
|
-
exchangeTag: string;
|
|
725
|
-
protected constructor(bindingParams: TBindingParams, type: ExchangeType);
|
|
726
|
-
protected generateExchangeTag(): string;
|
|
727
|
-
getBindingParams(): TBindingParams;
|
|
728
|
-
toJSON(): IExchangeSerialized<TBindingParams, ExchangeType>;
|
|
729
|
-
fromJSON(JSON: Partial<IExchangeSerialized<TBindingParams, ExchangeType>>): void;
|
|
730
|
-
protected abstract validateBindingParams(bindingParams: TBindingParams): TBindingParams;
|
|
731
|
-
abstract getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
declare class ExchangeDirect extends Exchange<TExchangeDirectBindingParams, EExchangeType.DIRECT> {
|
|
735
|
-
constructor(queue: TExchangeDirectBindingParams);
|
|
736
|
-
protected validateBindingParams(queue: TExchangeDirectBindingParams): IQueueParams;
|
|
737
|
-
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
declare class ExchangeTopic extends Exchange<TExchangeTopicBindingParams, EExchangeType.TOPIC> {
|
|
741
|
-
constructor(topic: TExchangeTopicBindingParams);
|
|
742
|
-
protected validateBindingParams(topicParams: TExchangeTopicBindingParams): TTopicParams;
|
|
743
|
-
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
declare class ExchangeFanOut extends Exchange<TExchangeFanOutBindingParams, EExchangeType.FANOUT> {
|
|
747
|
-
constructor(fanOutName: TExchangeFanOutBindingParams);
|
|
748
|
-
protected validateBindingParams(bindingParams: TExchangeFanOutBindingParams): string;
|
|
749
|
-
getQueues(cb: ICallback<IQueueParams[]>): void;
|
|
750
|
-
saveExchange(cb: ICallback<void>): void;
|
|
751
|
-
deleteExchange(cb: ICallback<void>): void;
|
|
752
|
-
bindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
753
|
-
unbindQueue(queue: IQueueParams | string, cb: ICallback<void>): void;
|
|
754
|
-
static getAllExchanges(cb: ICallback<string[]>): void;
|
|
755
|
-
static getQueueExchange(queue: IQueueParams | string, cb: ICallback<ExchangeFanOut | null>): void;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
754
|
declare class Namespace {
|
|
759
755
|
getNamespaces(cb: ICallback<string[]>): void;
|
|
760
756
|
getNamespaceQueues(namespace: string, cb: ICallback<IQueueParams[]>): void;
|
|
@@ -855,4 +851,4 @@ declare class Configuration {
|
|
|
855
851
|
|
|
856
852
|
declare function disconnect(cb: ICallback<void>): void;
|
|
857
853
|
|
|
858
|
-
export { Configuration, Consumer, ConsumerError, ConsumerMessageHandlerAlreadyExistsError, EConsumeMessageDeadLetterCause, EConsumeMessageUnacknowledgedCause, EExchangeType, EMessagePriority, EMessageProperty, EMessagePropertyStatus, EQueueProperty, EQueueType, ExchangeDirect, ExchangeError, ExchangeFanOut, ExchangeFanOutError, ExchangeInvalidDataError, ExchangeTopic, type IConsumableMessage, type IConsumerHeartbeat, type IConsumerHeartbeatPayload, type IConsumerMessageHandlerArgs, type IEventListener, type IExchange, type IExchangeSerialized, type IMessageSerialized, type IMessageStateSerialized, type IMessagesConfig, type IMessagesConfigStorage, type IMessagesConfigStorageOptions, type IMessagesConfigStorageOptionsRequired, type IMessagesConfigStorageRequired, type IQueueMessages, type IQueueMessagesCount, type IQueueMessagesPage, type IQueueMessagesPageParams, type IQueueParams, type IQueueProperties, type IQueueRateLimit, type IRedisSMQConfig, type IRedisSMQConfigRequired, Message, MessageDeleteError, MessageDestinationQueueAlreadySetError, MessageDestinationQueueRequiredError, MessageError, MessageExchangeRequiredError, MessageNotFoundError, Namespace, Producer, ProducerError, ProducerInstanceNotRunningError, ProducerMessageNotPublishedError, ProducerMessageNotScheduledError, ProducibleMessage, Queue, QueueAcknowledgedMessages, QueueDeadLetteredMessages, QueueError, QueueExistsError, QueueHasRunningConsumersError, QueueMessageRequeueError, QueueMessages, QueueNamespaceNotFoundError, QueueNotEmptyError, QueueNotFoundError, QueuePendingMessages, QueueRateLimit, QueueRateLimitError, QueueScheduledMessages, type TConsumerMessageHandler, type TConsumerRedisKeys, type TEventListenersConfig, type TExchange, type
|
|
854
|
+
export { Configuration, Consumer, ConsumerError, ConsumerMessageHandlerAlreadyExistsError, EConsumeMessageDeadLetterCause, EConsumeMessageUnacknowledgedCause, EExchangeType, EMessagePriority, EMessageProperty, EMessagePropertyStatus, EQueueProperty, EQueueType, ExchangeDirect, ExchangeError, ExchangeFanOut, ExchangeFanOutError, ExchangeInvalidDataError, ExchangeTopic, type IConsumableMessage, type IConsumerHeartbeat, type IConsumerHeartbeatPayload, type IConsumerMessageHandlerArgs, type IEventListener, type IExchange, type IExchangeSerialized, type IMessageSerialized, type IMessageStateSerialized, type IMessagesConfig, type IMessagesConfigStorage, type IMessagesConfigStorageOptions, type IMessagesConfigStorageOptionsRequired, type IMessagesConfigStorageRequired, type IQueueMessages, type IQueueMessagesCount, type IQueueMessagesPage, type IQueueMessagesPageParams, type IQueueParams, type IQueueProperties, type IQueueRateLimit, type IRedisSMQConfig, type IRedisSMQConfigRequired, Message, MessageDeleteError, MessageDestinationQueueAlreadySetError, MessageDestinationQueueRequiredError, MessageError, MessageExchangeRequiredError, MessageNotFoundError, Namespace, Producer, ProducerError, ProducerInstanceNotRunningError, ProducerMessageNotPublishedError, ProducerMessageNotScheduledError, ProducibleMessage, Queue, QueueAcknowledgedMessages, QueueDeadLetteredMessages, QueueError, QueueExistsError, QueueHasRunningConsumersError, QueueMessageRequeueError, QueueMessages, QueueNamespaceNotFoundError, QueueNotEmptyError, QueueNotFoundError, QueuePendingMessages, QueueRateLimit, QueueRateLimitError, QueueScheduledMessages, type TConsumerMessageHandler, type TConsumerRedisKeys, type TEventListenersConfig, type TExchange, type TExchangeDirectBindingParams, type TExchangeFanOutBindingParams, type TExchangeSerialized, type TExchangeTopicBindingParams, type TMessageConsumeOptions, type TQueueConsumer, type TRedisSMQEvent, type TTopicParams, disconnect };
|
package/dist/index.js
CHANGED
|
@@ -343,7 +343,7 @@ var EConsumeMessageUnacknowledgedCause = /* @__PURE__ */ ((EConsumeMessageUnackn
|
|
|
343
343
|
return EConsumeMessageUnacknowledgedCause3;
|
|
344
344
|
})(EConsumeMessageUnacknowledgedCause || {});
|
|
345
345
|
|
|
346
|
-
// types/exchange/
|
|
346
|
+
// types/exchange/common.ts
|
|
347
347
|
var EExchangeType = /* @__PURE__ */ ((EExchangeType2) => {
|
|
348
348
|
EExchangeType2[EExchangeType2["DIRECT"] = 0] = "DIRECT";
|
|
349
349
|
EExchangeType2[EExchangeType2["FANOUT"] = 1] = "FANOUT";
|
|
@@ -791,6 +791,9 @@ var Base = class extends EventEmitter2 {
|
|
|
791
791
|
cb
|
|
792
792
|
);
|
|
793
793
|
}
|
|
794
|
+
hasEventListeners() {
|
|
795
|
+
return !!Configuration.getSetConfig().eventListeners.length;
|
|
796
|
+
}
|
|
794
797
|
handleError(err) {
|
|
795
798
|
if (this.powerSwitch.isGoingUp() || this.powerSwitch.isRunning()) {
|
|
796
799
|
throw err;
|
|
@@ -3951,24 +3954,23 @@ var Consumer = class extends Base {
|
|
|
3951
3954
|
}
|
|
3952
3955
|
registerSystemEventListeners() {
|
|
3953
3956
|
super.registerSystemEventListeners();
|
|
3954
|
-
this.
|
|
3955
|
-
|
|
3957
|
+
if (this.hasEventListeners()) {
|
|
3958
|
+
this.on("messageAcknowledged", (...args) => {
|
|
3956
3959
|
this.eventListeners.forEach(
|
|
3957
3960
|
(i) => i.emit("messageAcknowledged", ...args)
|
|
3958
3961
|
);
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
if (this.eventListeners.length)
|
|
3962
|
+
});
|
|
3963
|
+
this.on("messageUnacknowledged", (...args) => {
|
|
3962
3964
|
this.eventListeners.forEach(
|
|
3963
3965
|
(i) => i.emit("messageUnacknowledged", ...args)
|
|
3964
3966
|
);
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
if (this.eventListeners.length)
|
|
3967
|
+
});
|
|
3968
|
+
this.on("messageDeadLettered", (...args) => {
|
|
3968
3969
|
this.eventListeners.forEach(
|
|
3969
3970
|
(i) => i.emit("messageDeadLettered", ...args)
|
|
3970
3971
|
);
|
|
3971
|
-
|
|
3972
|
+
});
|
|
3973
|
+
}
|
|
3972
3974
|
}
|
|
3973
3975
|
goingUp() {
|
|
3974
3976
|
return super.goingUp().concat([
|
|
@@ -4063,10 +4065,11 @@ function _scheduleMessage(mixed, message, cb) {
|
|
|
4063
4065
|
var Producer = class extends Base {
|
|
4064
4066
|
registerSystemEventListeners() {
|
|
4065
4067
|
super.registerSystemEventListeners();
|
|
4066
|
-
this.
|
|
4067
|
-
|
|
4068
|
+
if (this.hasEventListeners()) {
|
|
4069
|
+
this.on("messagePublished", (...args) => {
|
|
4068
4070
|
this.eventListeners.forEach((i) => i.emit("messagePublished", ...args));
|
|
4069
|
-
|
|
4071
|
+
});
|
|
4072
|
+
}
|
|
4070
4073
|
}
|
|
4071
4074
|
enqueue(redisClient2, queue, message, cb) {
|
|
4072
4075
|
var _a;
|
|
@@ -44,40 +44,45 @@ local function updateQueue()
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
local function deleteMessage()
|
|
47
|
-
local deleted = 0;
|
|
48
47
|
local messageStatus = redis.call("HGET", keyMessage, EMessagePropertyStatus)
|
|
49
|
-
if messageStatus
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
48
|
+
if messageStatus == false then
|
|
49
|
+
return 'MESSAGE_NOT_FOUND'
|
|
50
|
+
end
|
|
51
|
+
if messageStatus == EMessagePropertyStatusProcessing then
|
|
52
|
+
return 'MESSAGE_IN_PROCESS'
|
|
53
|
+
end
|
|
54
|
+
local deleted = 0;
|
|
55
|
+
if messageStatus == EMessagePropertyStatusAcknowledged then
|
|
56
|
+
deleted = redis.call("LREM", keyQueueAcknowledged, 1, messageId)
|
|
57
|
+
elseif messageStatus == EMessagePropertyStatusDeadLettered then
|
|
58
|
+
deleted = redis.call("LREM", keyQueueDL, 1, messageId)
|
|
59
|
+
elseif messageStatus == EMessagePropertyStatusScheduled then
|
|
60
|
+
deleted = redis.call("ZREM", keyScheduledMessages, messageId)
|
|
61
|
+
redis.call("ZREM", keyQueueScheduled, messageId)
|
|
62
|
+
elseif messageStatus == EMessagePropertyStatusUnackDelaying then
|
|
63
|
+
deleted = redis.call("LREM", keyDelayedMessages, 1, messageId)
|
|
64
|
+
elseif messageStatus == EMessagePropertyStatusUnackRequeuing then
|
|
65
|
+
deleted = redis.call("LREM", keyRequeueMessages, 1, messageId)
|
|
66
|
+
elseif messageStatus == EMessagePropertyStatusPending then
|
|
67
|
+
local queueType = redis.call("HGET", keyQueueProperties, EQueuePropertyQueueType)
|
|
68
|
+
if queueType ~= false then
|
|
69
|
+
if queueType == EQueuePropertyQueueTypePriorityQueue then
|
|
70
|
+
deleted = redis.call("ZREM", keyPriorityQueuePending, messageId)
|
|
71
|
+
end
|
|
72
|
+
if queueType == EQueuePropertyQueueTypeFIFOQueue or queueType == EQueuePropertyQueueTypeLIFOQueue then
|
|
73
|
+
deleted = redis.call("LREM", keyQueuePending, 1, messageId)
|
|
70
74
|
end
|
|
71
75
|
end
|
|
72
76
|
end
|
|
73
77
|
if deleted == 1 then
|
|
74
78
|
redis.call("DEL", keyMessage)
|
|
75
|
-
return
|
|
79
|
+
return 'OK'
|
|
76
80
|
end
|
|
77
|
-
return
|
|
81
|
+
return 'MESSAGE_NOT_DELETED'
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
|
|
85
|
+
local deleteMessageStatus = 'INVALID_PARAMETERS'
|
|
81
86
|
|
|
82
87
|
if #ARGV > argvIndexOffset then
|
|
83
88
|
for index in pairs(ARGV) do
|
|
@@ -91,13 +96,13 @@ if #ARGV > argvIndexOffset then
|
|
|
91
96
|
keyQueueScheduled = KEYS[keyIndexOffset + 6]
|
|
92
97
|
keyPriorityQueuePending = KEYS[keyIndexOffset + 7]
|
|
93
98
|
keyIndexOffset = keyIndexOffset + 7
|
|
94
|
-
|
|
95
|
-
if
|
|
96
|
-
|
|
99
|
+
deleteMessageStatus = deleteMessage()
|
|
100
|
+
if deleteMessageStatus ~= 'OK' then
|
|
101
|
+
break
|
|
97
102
|
end
|
|
103
|
+
updateQueue()
|
|
98
104
|
end
|
|
99
105
|
end
|
|
100
|
-
return 'OK'
|
|
101
106
|
end
|
|
102
107
|
|
|
103
|
-
return
|
|
108
|
+
return deleteMessageStatus
|