redis-smq 7.0.7 → 7.1.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.
- package/CHANGELOG.md +65 -0
- package/README.md +16 -11
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -1
- package/dist/misc/health-check/combined-run.js +6 -6
- package/dist/src/common/redis-keys/redis-keys.d.ts +19 -9
- package/dist/src/common/redis-keys/redis-keys.js +16 -9
- package/dist/src/lib/consumer/consumer-message-handler/acknowledge-message.js +1 -1
- package/dist/src/lib/consumer/consumer-message-handler/dead-letter-message.js +2 -2
- package/dist/src/lib/consumer/consumer-message-handler/delay-message.js +2 -2
- package/dist/src/lib/consumer/consumer-message-handler/requeue-message.js +1 -1
- package/dist/src/lib/exchange/direct-exchange.d.ts +10 -0
- package/dist/src/lib/exchange/direct-exchange.js +34 -0
- package/dist/src/lib/exchange/errors/destination-queue-required.error.d.ts +4 -0
- package/dist/src/lib/exchange/errors/destination-queue-required.error.js +11 -0
- package/dist/src/lib/exchange/errors/exchange.error.d.ts +3 -0
- package/dist/src/lib/exchange/errors/exchange.error.js +8 -0
- package/dist/src/lib/exchange/errors/invalid-exchange-data.error.d.ts +4 -0
- package/dist/src/lib/exchange/errors/invalid-exchange-data.error.js +11 -0
- package/dist/src/lib/exchange/exchange.d.ts +19 -0
- package/dist/src/lib/exchange/exchange.js +51 -0
- package/dist/src/lib/exchange/fan-out-exchange-manager.d.ts +21 -0
- package/dist/src/lib/exchange/fan-out-exchange-manager.js +160 -0
- package/dist/src/lib/exchange/fan-out-exchange.d.ts +10 -0
- package/dist/src/lib/exchange/fan-out-exchange.js +28 -0
- package/dist/src/lib/exchange/topic-exchange.d.ts +12 -0
- package/dist/src/lib/exchange/topic-exchange.js +58 -0
- package/dist/src/lib/message/errors/message-exchange-required.error.d.ts +4 -0
- package/dist/src/lib/message/errors/message-exchange-required.error.js +11 -0
- package/dist/src/lib/message/errors/message.error.d.ts +3 -0
- package/dist/src/lib/message/errors/message.error.js +8 -0
- package/dist/src/lib/message/{message-metadata.d.ts → message-state.d.ts} +12 -12
- package/dist/src/lib/message/{message-metadata.js → message-state.js} +4 -4
- package/dist/src/lib/message/message.d.ts +19 -10
- package/dist/src/lib/message/message.js +135 -77
- package/dist/src/lib/message-manager/message-storage/list.js +6 -5
- package/dist/src/lib/producer/errors/message-already-published.error.js +1 -1
- package/dist/src/lib/producer/producer.d.ts +4 -2
- package/dist/src/lib/producer/producer.js +61 -37
- package/dist/src/lib/producer/schedule-message.js +6 -5
- package/dist/src/lib/queue-manager/delete-queue-transaction.js +11 -3
- package/dist/src/lib/queue-manager/queue-manager.d.ts +3 -2
- package/dist/src/lib/queue-manager/queue-manager.js +3 -3
- package/dist/src/lib/queue-manager/queue-rate-limit.js +7 -6
- package/dist/src/lib/queue-manager/queue.d.ts +4 -1
- package/dist/src/lib/queue-manager/queue.js +24 -8
- package/dist/src/workers/delay.worker.js +2 -2
- package/dist/src/workers/requeue.worker.js +2 -2
- package/dist/src/workers/schedule.worker.js +5 -4
- package/dist/types/index.d.ts +37 -4
- package/dist/types/index.js +13 -1
- package/package.json +3 -3
- package/dist/src/lib/producer/errors/message-queue-required.error.d.ts +0 -4
- package/dist/src/lib/producer/errors/message-queue-required.error.js +0 -11
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FanOutExchangeManager = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const redis_smq_common_1 = require("redis-smq-common");
|
|
6
|
+
const fan_out_exchange_1 = require("./fan-out-exchange");
|
|
7
|
+
const queue_1 = require("../queue-manager/queue");
|
|
8
|
+
const redis_keys_1 = require("../../common/redis-keys/redis-keys");
|
|
9
|
+
const configuration_1 = require("../../config/configuration");
|
|
10
|
+
const exchange_error_1 = require("./errors/exchange.error");
|
|
11
|
+
class FanOutExchangeManager {
|
|
12
|
+
constructor(config, redisClient, logger) {
|
|
13
|
+
this.redisClient = redisClient;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
17
|
+
createExchange(exchange, cb) {
|
|
18
|
+
const { keyExchanges } = redis_keys_1.redisKeys.getMainKeys();
|
|
19
|
+
this.redisClient.sadd(keyExchanges, exchange.getBindingParams(), (err) => cb(err));
|
|
20
|
+
}
|
|
21
|
+
deleteExchange(exchange, cb) {
|
|
22
|
+
const { keyExchanges, keyExchangeBindings } = redis_keys_1.redisKeys.getFanOutExchangeKeys(exchange.getBindingParams());
|
|
23
|
+
this.redisClient.watch([keyExchanges, keyExchangeBindings], (err) => {
|
|
24
|
+
if (err)
|
|
25
|
+
cb(err);
|
|
26
|
+
else {
|
|
27
|
+
this.getExchangeQueues(exchange, (err, reply = []) => {
|
|
28
|
+
if (err)
|
|
29
|
+
cb(err);
|
|
30
|
+
else if (reply.length)
|
|
31
|
+
cb(new exchange_error_1.ExchangeError(`Exchange has ${reply.length} bound queue(s). Unbind all queues before deleting the exchange.`));
|
|
32
|
+
else {
|
|
33
|
+
const multi = this.redisClient.multi();
|
|
34
|
+
multi.srem(keyExchanges, exchange.getBindingParams());
|
|
35
|
+
multi.del(keyExchangeBindings);
|
|
36
|
+
multi.exec((err) => cb(err));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
bindQueue(queue, exchange, cb) {
|
|
43
|
+
redis_smq_common_1.async.waterfall([
|
|
44
|
+
(cb) => queue_1.Queue.getSettings(this.config, this.redisClient, queue, cb),
|
|
45
|
+
(queueSettings, cb) => {
|
|
46
|
+
const exchangeParams = exchange.getBindingParams();
|
|
47
|
+
const currentExchangeParams = queueSettings.exchange;
|
|
48
|
+
if (currentExchangeParams === exchangeParams)
|
|
49
|
+
cb();
|
|
50
|
+
else {
|
|
51
|
+
const { keyExchanges, keyExchangeBindings } = redis_keys_1.redisKeys.getFanOutExchangeKeys(exchangeParams);
|
|
52
|
+
const queueParams = queue_1.Queue.getParams(this.config, queue);
|
|
53
|
+
const { keyQueues, keyQueueSettings } = redis_keys_1.redisKeys.getQueueKeys(queueParams);
|
|
54
|
+
this.redisClient.watch([keyQueues, keyQueueSettings, keyExchangeBindings], (err) => {
|
|
55
|
+
if (err)
|
|
56
|
+
cb(err);
|
|
57
|
+
else {
|
|
58
|
+
const multi = this.redisClient.multi();
|
|
59
|
+
const queueParamsStr = JSON.stringify(queueParams);
|
|
60
|
+
multi.sadd(keyExchanges, exchangeParams);
|
|
61
|
+
multi.sadd(keyExchangeBindings, queueParamsStr);
|
|
62
|
+
multi.hset(keyQueueSettings, types_1.EQueueSettingType.EXCHANGE, exchangeParams);
|
|
63
|
+
if (currentExchangeParams) {
|
|
64
|
+
const { keyExchangeBindings } = redis_keys_1.redisKeys.getFanOutExchangeKeys(currentExchangeParams);
|
|
65
|
+
multi.srem(keyExchangeBindings, queueParamsStr);
|
|
66
|
+
}
|
|
67
|
+
multi.exec((err) => cb(err));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
], (err) => {
|
|
73
|
+
if (err)
|
|
74
|
+
this.redisClient.unwatch(() => cb(err));
|
|
75
|
+
else
|
|
76
|
+
cb();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
unbindQueue(queue, exchange, cb) {
|
|
80
|
+
redis_smq_common_1.async.waterfall([
|
|
81
|
+
(cb) => queue_1.Queue.getSettings(this.config, this.redisClient, queue, cb),
|
|
82
|
+
(queueSettings, cb) => {
|
|
83
|
+
const queueParams = queue_1.Queue.getParams(this.config, queue);
|
|
84
|
+
const exchangeName = exchange.getBindingParams();
|
|
85
|
+
if (queueSettings.exchange !== exchangeName)
|
|
86
|
+
cb(new exchange_error_1.ExchangeError(`Queue ${queueParams.name}@${queueParams.ns} is not bound to [${exchangeName}] exchange.`));
|
|
87
|
+
else {
|
|
88
|
+
const { keyExchangeBindings } = redis_keys_1.redisKeys.getFanOutExchangeKeys(queueSettings.exchange);
|
|
89
|
+
const { keyQueues, keyQueueSettings } = redis_keys_1.redisKeys.getQueueKeys(queueParams);
|
|
90
|
+
this.redisClient.watch([keyQueues, keyQueueSettings, keyExchangeBindings], (err) => {
|
|
91
|
+
if (err)
|
|
92
|
+
cb(err);
|
|
93
|
+
else {
|
|
94
|
+
const multi = this.redisClient.multi();
|
|
95
|
+
const queueParamsStr = JSON.stringify(queueParams);
|
|
96
|
+
multi.srem(keyExchangeBindings, queueParamsStr);
|
|
97
|
+
multi.hdel(keyQueueSettings, types_1.EQueueSettingType.EXCHANGE);
|
|
98
|
+
multi.exec((err) => cb(err));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
], (err) => {
|
|
104
|
+
if (err)
|
|
105
|
+
this.redisClient.unwatch(() => cb(err));
|
|
106
|
+
else
|
|
107
|
+
cb();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getExchanges(cb) {
|
|
111
|
+
const { keyExchanges } = redis_keys_1.redisKeys.getMainKeys();
|
|
112
|
+
this.redisClient.sscanFallback(keyExchanges, cb);
|
|
113
|
+
}
|
|
114
|
+
getExchangeQueues(exchange, cb) {
|
|
115
|
+
FanOutExchangeManager.getExchangeQueues(this.redisClient, exchange, cb);
|
|
116
|
+
}
|
|
117
|
+
getQueueExchange(queue, cb) {
|
|
118
|
+
FanOutExchangeManager.getQueueExchange(this.config, this.redisClient, queue, cb);
|
|
119
|
+
}
|
|
120
|
+
quit(cb) {
|
|
121
|
+
this.redisClient.halt(cb);
|
|
122
|
+
}
|
|
123
|
+
static getExchangeQueues(redisClient, exchange, cb) {
|
|
124
|
+
const { keyExchangeBindings } = redis_keys_1.redisKeys.getFanOutExchangeKeys(exchange.getBindingParams());
|
|
125
|
+
redisClient.sscanFallback(keyExchangeBindings, (err, reply) => {
|
|
126
|
+
if (err)
|
|
127
|
+
cb(err);
|
|
128
|
+
else {
|
|
129
|
+
const queues = (reply !== null && reply !== void 0 ? reply : []).map((i) => JSON.parse(i));
|
|
130
|
+
cb(null, queues);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
static getQueueExchange(config, redisClient, queue, cb) {
|
|
135
|
+
queue_1.Queue.getSettings(config, redisClient, queue, (err, reply) => {
|
|
136
|
+
if (err)
|
|
137
|
+
cb(err);
|
|
138
|
+
else
|
|
139
|
+
cb(null, (reply === null || reply === void 0 ? void 0 : reply.exchange) ? new fan_out_exchange_1.FanOutExchange(reply.exchange) : null);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
static createInstance(config = {}, cb) {
|
|
143
|
+
const cfg = (0, configuration_1.getConfiguration)(config);
|
|
144
|
+
const redis = cfg.redis;
|
|
145
|
+
(0, redis_smq_common_1.createClientInstance)(redis, (err, client) => {
|
|
146
|
+
if (err)
|
|
147
|
+
cb(err);
|
|
148
|
+
else if (!client)
|
|
149
|
+
cb(new redis_smq_common_1.errors.EmptyCallbackReplyError());
|
|
150
|
+
else {
|
|
151
|
+
const loggerCfg = cfg.logger;
|
|
152
|
+
const nsLogger = redis_smq_common_1.logger.getNamespacedLogger(loggerCfg, 'queue-manager');
|
|
153
|
+
const fanOutExchangeManager = new FanOutExchangeManager(cfg, client, nsLogger);
|
|
154
|
+
cb(null, fanOutExchangeManager);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.FanOutExchangeManager = FanOutExchangeManager;
|
|
160
|
+
//# sourceMappingURL=fan-out-exchange-manager.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exchange } from './exchange';
|
|
2
|
+
import { EExchangeType, IFanOutExchangeParams, IRequiredConfig, TQueueParams } from '../../../types';
|
|
3
|
+
import { RedisClient } from 'redis-smq-common';
|
|
4
|
+
import { ICallback } from 'redis-smq-common/dist/types';
|
|
5
|
+
export declare class FanOutExchange extends Exchange<string, EExchangeType.FANOUT> {
|
|
6
|
+
constructor(fanOutName: string);
|
|
7
|
+
protected validateBindingParams(bindingParams: string): string;
|
|
8
|
+
getQueues(redisClient: RedisClient, config: IRequiredConfig, cb: ICallback<TQueueParams[]>): void;
|
|
9
|
+
static fromJSON(json: Partial<IFanOutExchangeParams>): FanOutExchange;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FanOutExchange = void 0;
|
|
4
|
+
const exchange_1 = require("./exchange");
|
|
5
|
+
const types_1 = require("../../../types");
|
|
6
|
+
const invalid_exchange_data_error_1 = require("./errors/invalid-exchange-data.error");
|
|
7
|
+
const fan_out_exchange_manager_1 = require("./fan-out-exchange-manager");
|
|
8
|
+
const redis_keys_1 = require("../../common/redis-keys/redis-keys");
|
|
9
|
+
class FanOutExchange extends exchange_1.Exchange {
|
|
10
|
+
constructor(fanOutName) {
|
|
11
|
+
super(fanOutName, types_1.EExchangeType.FANOUT);
|
|
12
|
+
}
|
|
13
|
+
validateBindingParams(bindingParams) {
|
|
14
|
+
return redis_keys_1.redisKeys.validateRedisKey(bindingParams);
|
|
15
|
+
}
|
|
16
|
+
getQueues(redisClient, config, cb) {
|
|
17
|
+
fan_out_exchange_manager_1.FanOutExchangeManager.getExchangeQueues(redisClient, this, cb);
|
|
18
|
+
}
|
|
19
|
+
static fromJSON(json) {
|
|
20
|
+
if (!json.bindingParams || json.type !== types_1.EExchangeType.FANOUT)
|
|
21
|
+
throw new invalid_exchange_data_error_1.InvalidExchangeDataError();
|
|
22
|
+
const e = new FanOutExchange(json.bindingParams);
|
|
23
|
+
e.fromJSON(json);
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.FanOutExchange = FanOutExchange;
|
|
28
|
+
//# sourceMappingURL=fan-out-exchange.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exchange } from './exchange';
|
|
2
|
+
import { EExchangeType, IRequiredConfig, ITopicExchangeParams, TQueueParams, TTopicParams } from '../../../types';
|
|
3
|
+
import { RedisClient } from 'redis-smq-common';
|
|
4
|
+
import { ICallback } from 'redis-smq-common/dist/types';
|
|
5
|
+
export declare class TopicExchange extends Exchange<TTopicParams | string, EExchangeType.TOPIC> {
|
|
6
|
+
constructor(topic: TTopicParams | string);
|
|
7
|
+
protected validateBindingParams(topicParams: TTopicParams | string): TTopicParams | string;
|
|
8
|
+
protected getTopicParams(config: IRequiredConfig): TTopicParams;
|
|
9
|
+
matchQueues(config: IRequiredConfig, queues: TQueueParams[], cb: ICallback<TQueueParams[]>): void;
|
|
10
|
+
getQueues(redisClient: RedisClient, config: IRequiredConfig, cb: ICallback<TQueueParams[]>): void;
|
|
11
|
+
static fromJSON(json: Partial<ITopicExchangeParams>): TopicExchange;
|
|
12
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TopicExchange = void 0;
|
|
4
|
+
const exchange_1 = require("./exchange");
|
|
5
|
+
const types_1 = require("../../../types");
|
|
6
|
+
const redis_smq_common_1 = require("redis-smq-common");
|
|
7
|
+
const queue_1 = require("../queue-manager/queue");
|
|
8
|
+
const redis_keys_1 = require("../../common/redis-keys/redis-keys");
|
|
9
|
+
const invalid_exchange_data_error_1 = require("./errors/invalid-exchange-data.error");
|
|
10
|
+
class TopicExchange extends exchange_1.Exchange {
|
|
11
|
+
constructor(topic) {
|
|
12
|
+
super(topic, types_1.EExchangeType.TOPIC);
|
|
13
|
+
}
|
|
14
|
+
validateBindingParams(topicParams) {
|
|
15
|
+
return typeof topicParams === 'string'
|
|
16
|
+
? redis_keys_1.redisKeys.validateRedisKey(topicParams)
|
|
17
|
+
: {
|
|
18
|
+
topic: redis_keys_1.redisKeys.validateRedisKey(topicParams.topic),
|
|
19
|
+
ns: redis_keys_1.redisKeys.validateNamespace(topicParams.ns),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getTopicParams(config) {
|
|
23
|
+
if (typeof this.bindingParams === 'string') {
|
|
24
|
+
return {
|
|
25
|
+
topic: this.bindingParams,
|
|
26
|
+
ns: config.namespace,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return this.bindingParams;
|
|
30
|
+
}
|
|
31
|
+
matchQueues(config, queues, cb) {
|
|
32
|
+
const topicParams = this.getTopicParams(config);
|
|
33
|
+
const matched = [];
|
|
34
|
+
const regExp = new RegExp(topicParams.topic);
|
|
35
|
+
redis_smq_common_1.async.eachOf(queues, (queue, index, done) => {
|
|
36
|
+
if (queue.ns === topicParams.ns && regExp.test(queue.name))
|
|
37
|
+
matched.push(queue);
|
|
38
|
+
done();
|
|
39
|
+
}, (err) => cb(err, matched));
|
|
40
|
+
}
|
|
41
|
+
getQueues(redisClient, config, cb) {
|
|
42
|
+
queue_1.Queue.list(redisClient, (err, reply) => {
|
|
43
|
+
if (err)
|
|
44
|
+
cb(err);
|
|
45
|
+
else
|
|
46
|
+
this.matchQueues(config, reply !== null && reply !== void 0 ? reply : [], cb);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
static fromJSON(json) {
|
|
50
|
+
if (!json.bindingParams || json.type !== types_1.EExchangeType.TOPIC)
|
|
51
|
+
throw new invalid_exchange_data_error_1.InvalidExchangeDataError();
|
|
52
|
+
const e = new TopicExchange(json.bindingParams);
|
|
53
|
+
e.fromJSON(json);
|
|
54
|
+
return e;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.TopicExchange = TopicExchange;
|
|
58
|
+
//# sourceMappingURL=topic-exchange.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageExchangeRequiredError = void 0;
|
|
4
|
+
const message_error_1 = require("./message.error");
|
|
5
|
+
class MessageExchangeRequiredError extends message_error_1.MessageError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(`A message exchange is required`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MessageExchangeRequiredError = MessageExchangeRequiredError;
|
|
11
|
+
//# sourceMappingURL=message-exchange-required.error.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageError = void 0;
|
|
4
|
+
const redis_smq_error_1 = require("redis-smq-common/dist/src/errors/redis-smq.error");
|
|
5
|
+
class MessageError extends redis_smq_error_1.RedisSMQError {
|
|
6
|
+
}
|
|
7
|
+
exports.MessageError = MessageError;
|
|
8
|
+
//# sourceMappingURL=message.error.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class
|
|
1
|
+
import { TMessageState } from '../../../types';
|
|
2
|
+
export declare class MessageState {
|
|
3
3
|
protected readonly uuid: string;
|
|
4
4
|
protected publishedAt: number | null;
|
|
5
5
|
protected scheduledAt: number | null;
|
|
@@ -10,20 +10,20 @@ export declare class MessageMetadata {
|
|
|
10
10
|
protected nextScheduledDelay: number;
|
|
11
11
|
protected nextRetryDelay: number;
|
|
12
12
|
constructor();
|
|
13
|
-
setPublishedAt(timestamp: number):
|
|
14
|
-
setScheduledAt(timestamp: number):
|
|
15
|
-
setNextScheduledDelay(delay: number):
|
|
13
|
+
setPublishedAt(timestamp: number): MessageState;
|
|
14
|
+
setScheduledAt(timestamp: number): MessageState;
|
|
15
|
+
setNextScheduledDelay(delay: number): MessageState;
|
|
16
16
|
getSetNextScheduledDelay(): number;
|
|
17
|
-
setNextRetryDelay(delay: number):
|
|
17
|
+
setNextRetryDelay(delay: number): MessageState;
|
|
18
18
|
getSetNextRetryDelay(): number;
|
|
19
19
|
hasDelay(): boolean;
|
|
20
|
-
resetMessageScheduledRepeatCount():
|
|
20
|
+
resetMessageScheduledRepeatCount(): MessageState;
|
|
21
21
|
incrAttempts(): number;
|
|
22
|
-
setAttempts(attempts: number):
|
|
23
|
-
setMessageScheduledCronFired(fired: boolean):
|
|
22
|
+
setAttempts(attempts: number): MessageState;
|
|
23
|
+
setMessageScheduledCronFired(fired: boolean): MessageState;
|
|
24
24
|
incrMessageScheduledRepeatCount(): number;
|
|
25
|
-
setExpired(expired: boolean):
|
|
26
|
-
reset():
|
|
25
|
+
setExpired(expired: boolean): MessageState;
|
|
26
|
+
reset(): MessageState;
|
|
27
27
|
getPublishedAt(): number | null;
|
|
28
28
|
getScheduledAt(): number | null;
|
|
29
29
|
getAttempts(): number;
|
|
@@ -33,5 +33,5 @@ export declare class MessageMetadata {
|
|
|
33
33
|
hasExpired(): boolean;
|
|
34
34
|
getSetExpired(ttl: number, createdAt: number): boolean;
|
|
35
35
|
getSetNextDelay(): number;
|
|
36
|
-
toJSON():
|
|
36
|
+
toJSON(): TMessageState;
|
|
37
37
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MessageState = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
class
|
|
5
|
+
class MessageState {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.publishedAt = null;
|
|
8
8
|
this.scheduledAt = null;
|
|
@@ -142,5 +142,5 @@ class MessageMetadata {
|
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
exports.
|
|
146
|
-
//# sourceMappingURL=message-
|
|
145
|
+
exports.MessageState = MessageState;
|
|
146
|
+
//# sourceMappingURL=message-state.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TMessageConsumeOptions, TMessageJSON, TQueueParams } from '../../../types';
|
|
2
|
-
import {
|
|
1
|
+
import { TMessageConsumeOptions, TExchange, TMessageJSON, TQueueParams, TTopicParams } from '../../../types';
|
|
2
|
+
import { MessageState } from './message-state';
|
|
3
3
|
export declare class Message {
|
|
4
4
|
static readonly MessagePriority: {
|
|
5
5
|
LOWEST: number;
|
|
@@ -13,7 +13,6 @@ export declare class Message {
|
|
|
13
13
|
};
|
|
14
14
|
protected static defaultConsumeOptions: TMessageConsumeOptions;
|
|
15
15
|
protected readonly createdAt: number;
|
|
16
|
-
protected queue: string | TQueueParams | null;
|
|
17
16
|
protected ttl: number;
|
|
18
17
|
protected retryThreshold: number;
|
|
19
18
|
protected retryDelay: number;
|
|
@@ -24,16 +23,19 @@ export declare class Message {
|
|
|
24
23
|
protected scheduledDelay: number | null;
|
|
25
24
|
protected scheduledRepeatPeriod: number | null;
|
|
26
25
|
protected scheduledRepeat: number;
|
|
27
|
-
protected
|
|
26
|
+
protected messageState: MessageState | null;
|
|
27
|
+
protected exchange: TExchange | null;
|
|
28
28
|
constructor();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
getMessageState(): MessageState | null;
|
|
30
|
+
getRequiredMessageState(): MessageState;
|
|
31
|
+
setMessageState(m: MessageState): Message;
|
|
32
|
+
getSetMessageState(): MessageState;
|
|
32
33
|
getPublishedAt(): number | null;
|
|
33
34
|
getScheduledAt(): number | null;
|
|
34
35
|
getId(): string | null;
|
|
35
36
|
getRequiredId(): string;
|
|
36
37
|
getSetExpired(): boolean;
|
|
38
|
+
setExchange(exchange: TExchange): Message;
|
|
37
39
|
setScheduledRepeatPeriod(period: number): Message;
|
|
38
40
|
setScheduledDelay(delay: number): Message;
|
|
39
41
|
setScheduledCRON(cron: string): Message;
|
|
@@ -44,11 +46,16 @@ export declare class Message {
|
|
|
44
46
|
setRetryDelay(delay: number): Message;
|
|
45
47
|
setBody(body: unknown): Message;
|
|
46
48
|
setPriority(priority: number): Message;
|
|
47
|
-
|
|
49
|
+
setFanOut(bindingKey: string): Message;
|
|
50
|
+
setTopic(topicParams: string | TTopicParams): Message;
|
|
51
|
+
setQueue(queueParams: string | TQueueParams): Message;
|
|
52
|
+
setDestinationQueue(queue: TQueueParams): Message;
|
|
48
53
|
disablePriority(): Message;
|
|
49
54
|
hasPriority(): boolean;
|
|
50
55
|
getQueue(): TQueueParams | string | null;
|
|
51
|
-
|
|
56
|
+
getTopic(): TTopicParams | string | null;
|
|
57
|
+
getFanOutParams(): string | null;
|
|
58
|
+
getDestinationQueue(): TQueueParams;
|
|
52
59
|
getPriority(): number | null;
|
|
53
60
|
getBody(): unknown;
|
|
54
61
|
getTTL(): number;
|
|
@@ -62,6 +69,8 @@ export declare class Message {
|
|
|
62
69
|
getMessageScheduledDelay(): number | null;
|
|
63
70
|
hasNextDelay(): boolean;
|
|
64
71
|
getNextScheduledTimestamp(): number;
|
|
72
|
+
getExchange(): TExchange | null;
|
|
73
|
+
getRequiredExchange(): TExchange;
|
|
65
74
|
toString(): string;
|
|
66
75
|
toJSON(): TMessageJSON;
|
|
67
76
|
hasRetryThresholdExceeded(): boolean;
|
|
@@ -71,6 +80,6 @@ export declare class Message {
|
|
|
71
80
|
protected static validateTTL(ttl: unknown): number;
|
|
72
81
|
protected static validateConsumeTimeout(timeout: unknown): number;
|
|
73
82
|
protected static validateRetryThreshold(threshold: unknown): number;
|
|
74
|
-
static createFromMessage(message: string | Message,
|
|
83
|
+
static createFromMessage(message: string | Message, hardReset?: boolean): Message;
|
|
75
84
|
static setDefaultConsumeOptions(consumeOptions: Partial<TMessageConsumeOptions>): void;
|
|
76
85
|
}
|