redis-smq 6.2.0 → 6.2.3
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 +16 -0
- package/dist/src/monitor-server/services/queues.service.d.ts +3 -3
- package/dist/src/monitor-server/workers/websocket-heartbeat-stream.worker.js +0 -16
- package/dist/src/monitor-server/workers/websocket-main-stream.worker.js +0 -15
- package/dist/src/monitor-server/workers/websocket-online-stream.worker.js +0 -15
- package/dist/src/monitor-server/workers/websocket-rate-stream.worker.js +0 -16
- package/dist/src/system/app/consumer/consumer-message-handler.js +1 -1
- package/dist/src/system/app/consumer/consumer.js +4 -5
- package/dist/src/system/app/consumer/errors/consumer.error.d.ts +3 -0
- package/dist/src/system/app/consumer/{consumer.error.js → errors/consumer.error.js} +1 -1
- package/dist/src/system/app/consumer/errors/message-handler-already-exists.error.d.ts +5 -0
- package/dist/src/system/app/consumer/errors/message-handler-already-exists.error.js +11 -0
- package/dist/src/system/app/queue-manager/queue-manager-frontend.d.ts +3 -3
- package/dist/src/system/app/queue-manager/queue-manager-frontend.js +6 -3
- package/dist/src/system/common/worker/worker-runner/worker-runner.d.ts +1 -5
- package/dist/src/system/common/worker/worker-runner/worker-runner.js +3 -51
- package/dist/src/system/workers/delay.worker.js +0 -15
- package/dist/src/system/workers/heartbeat-monitor.worker.js +0 -15
- package/dist/src/system/workers/requeue.worker.js +0 -15
- package/dist/src/system/workers/schedule.worker.js +0 -14
- package/dist/src/system/workers/time-series.worker.js +0 -15
- package/package.json +2 -2
- package/dist/src/system/app/consumer/consumer.error.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 6.2.3 (2022-02-23)
|
|
4
|
+
|
|
5
|
+
* Bump up redis-smq-monitor to v6.5.3 (4e845d0)
|
|
6
|
+
* Remove gracefully a message handler (a4402b7)
|
|
7
|
+
* Add MessageHandlerAlreadyExistsError custom error (65882ed)
|
|
8
|
+
|
|
9
|
+
## 6.2.2 (2022-02-21)
|
|
10
|
+
|
|
11
|
+
* Fix a queue rate limiting bug allowing to save invalid Redis keys (1dc91aa)
|
|
12
|
+
* Bump up redis-smq-monitor to v6.5.2 (e192db0)
|
|
13
|
+
* Update docs (5a6469e)
|
|
14
|
+
|
|
15
|
+
## 6.2.1 (2022-02-19)
|
|
16
|
+
|
|
17
|
+
* Remove unused code (475fa3d)
|
|
18
|
+
|
|
3
19
|
## 6.2.0 (2022-02-19)
|
|
4
20
|
|
|
5
21
|
* Bump up redis-smq-monitor to v6.5.1 (c543c55)
|
|
@@ -7,9 +7,9 @@ import { SetRateLimitRequestDTO } from '../controllers/api/namespaces/queue/rate
|
|
|
7
7
|
import { ClearRateLimitRequestDTO } from '../controllers/api/namespaces/queue/rate-limiting/clear-rate-limit/clear-rate-limit.request.DTO';
|
|
8
8
|
import { GetRateLimitRequestDTO } from '../controllers/api/namespaces/queue/rate-limiting/get-rate-limit/get-rate-limit.request.DTO';
|
|
9
9
|
declare const queueManagerAsync: {
|
|
10
|
-
clearQueueRateLimitAsync: (queue: TQueueParams) => Promise<void>;
|
|
11
|
-
setQueueRateLimitAsync: (queue: TQueueParams, rateLimit: import("../../../types").TQueueRateLimit) => Promise<void>;
|
|
12
|
-
getQueueRateLimitAsync: (queue: TQueueParams) => Promise<import("../../../types").TQueueRateLimit>;
|
|
10
|
+
clearQueueRateLimitAsync: (queue: string | TQueueParams) => Promise<void>;
|
|
11
|
+
setQueueRateLimitAsync: (queue: string | TQueueParams, rateLimit: import("../../../types").TQueueRateLimit) => Promise<void>;
|
|
12
|
+
getQueueRateLimitAsync: (queue: string | TQueueParams) => Promise<import("../../../types").TQueueRateLimit>;
|
|
13
13
|
deleteQueueAsync: (queue: string | TQueueParams) => Promise<void>;
|
|
14
14
|
getNamespaceQueuesAsync: (ns: string) => Promise<TQueueParams[]>;
|
|
15
15
|
deleteNamespaceAsync: (ns: string) => Promise<void>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebsocketHeartbeatStreamWorker = void 0;
|
|
4
|
-
const redis_client_1 = require("../../system/common/redis-client/redis-client");
|
|
5
|
-
const empty_callback_reply_error_1 = require("../../system/common/errors/empty-callback-reply.error");
|
|
6
4
|
const consumer_heartbeat_1 = require("../../system/app/consumer/consumer-heartbeat");
|
|
7
|
-
const configuration_1 = require("../../system/common/configuration/configuration");
|
|
8
5
|
const worker_1 = require("../../system/common/worker/worker");
|
|
9
6
|
const async_1 = require("../../system/lib/async");
|
|
10
7
|
class WebsocketHeartbeatStreamWorker extends worker_1.Worker {
|
|
@@ -32,17 +29,4 @@ class WebsocketHeartbeatStreamWorker extends worker_1.Worker {
|
|
|
32
29
|
}
|
|
33
30
|
exports.WebsocketHeartbeatStreamWorker = WebsocketHeartbeatStreamWorker;
|
|
34
31
|
exports.default = WebsocketHeartbeatStreamWorker;
|
|
35
|
-
process.on('message', (payload) => {
|
|
36
|
-
const params = JSON.parse(payload);
|
|
37
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
38
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
39
|
-
if (err)
|
|
40
|
-
throw err;
|
|
41
|
-
else if (!client)
|
|
42
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
43
|
-
else {
|
|
44
|
-
new WebsocketHeartbeatStreamWorker(client, params, false).run();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
32
|
//# sourceMappingURL=websocket-heartbeat-stream.worker.js.map
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebsocketMainStreamWorker = void 0;
|
|
4
4
|
const redis_keys_1 = require("../../system/common/redis-keys/redis-keys");
|
|
5
|
-
const redis_client_1 = require("../../system/common/redis-client/redis-client");
|
|
6
5
|
const message_manager_1 = require("../../system/app/message-manager/message-manager");
|
|
7
|
-
const empty_callback_reply_error_1 = require("../../system/common/errors/empty-callback-reply.error");
|
|
8
6
|
const consumer_1 = require("../../system/app/consumer/consumer");
|
|
9
7
|
const queue_manager_1 = require("../../system/app/queue-manager/queue-manager");
|
|
10
|
-
const configuration_1 = require("../../system/common/configuration/configuration");
|
|
11
8
|
const worker_1 = require("../../system/common/worker/worker");
|
|
12
9
|
const async_1 = require("../../system/lib/async");
|
|
13
10
|
class WebsocketMainStreamWorker extends worker_1.Worker {
|
|
@@ -172,16 +169,4 @@ class WebsocketMainStreamWorker extends worker_1.Worker {
|
|
|
172
169
|
}
|
|
173
170
|
exports.WebsocketMainStreamWorker = WebsocketMainStreamWorker;
|
|
174
171
|
exports.default = WebsocketMainStreamWorker;
|
|
175
|
-
process.on('message', (payload) => {
|
|
176
|
-
const params = JSON.parse(payload);
|
|
177
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
178
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
179
|
-
if (err)
|
|
180
|
-
throw err;
|
|
181
|
-
else if (!client)
|
|
182
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
183
|
-
else
|
|
184
|
-
new WebsocketMainStreamWorker(client, params, false).run();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
172
|
//# sourceMappingURL=websocket-main-stream.worker.js.map
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebsocketOnlineStreamWorker = void 0;
|
|
4
|
-
const redis_client_1 = require("../../system/common/redis-client/redis-client");
|
|
5
|
-
const empty_callback_reply_error_1 = require("../../system/common/errors/empty-callback-reply.error");
|
|
6
4
|
const consumer_1 = require("../../system/app/consumer/consumer");
|
|
7
5
|
const queue_manager_1 = require("../../system/app/queue-manager/queue-manager");
|
|
8
|
-
const configuration_1 = require("../../system/common/configuration/configuration");
|
|
9
6
|
const worker_1 = require("../../system/common/worker/worker");
|
|
10
7
|
const async_1 = require("../../system/lib/async");
|
|
11
8
|
class WebsocketOnlineStreamWorker extends worker_1.Worker {
|
|
@@ -33,16 +30,4 @@ class WebsocketOnlineStreamWorker extends worker_1.Worker {
|
|
|
33
30
|
}
|
|
34
31
|
exports.WebsocketOnlineStreamWorker = WebsocketOnlineStreamWorker;
|
|
35
32
|
exports.default = WebsocketOnlineStreamWorker;
|
|
36
|
-
process.on('message', (payload) => {
|
|
37
|
-
const params = JSON.parse(payload);
|
|
38
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
39
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
40
|
-
if (err)
|
|
41
|
-
throw err;
|
|
42
|
-
else if (!client)
|
|
43
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
44
|
-
else
|
|
45
|
-
new WebsocketOnlineStreamWorker(client, params, false).run();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
33
|
//# sourceMappingURL=websocket-online-stream.worker.js.map
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebsocketRateStreamWorker = void 0;
|
|
4
4
|
const redis_keys_1 = require("../../system/common/redis-keys/redis-keys");
|
|
5
|
-
const redis_client_1 = require("../../system/common/redis-client/redis-client");
|
|
6
|
-
const empty_callback_reply_error_1 = require("../../system/common/errors/empty-callback-reply.error");
|
|
7
5
|
const consumer_heartbeat_1 = require("../../system/app/consumer/consumer-heartbeat");
|
|
8
6
|
const time_series_1 = require("../../system/common/time-series/time-series");
|
|
9
7
|
const queue_published_time_series_1 = require("../../system/app/producer/producer-time-series/queue-published-time-series");
|
|
@@ -15,7 +13,6 @@ const global_dead_lettered_time_series_1 = require("../../system/app/consumer/co
|
|
|
15
13
|
const consumer_acknowledged_time_series_1 = require("../../system/app/consumer/consumer-time-series/consumer-acknowledged-time-series");
|
|
16
14
|
const consumer_dead_lettered_time_series_1 = require("../../system/app/consumer/consumer-time-series/consumer-dead-lettered-time-series");
|
|
17
15
|
const consumer_queues_1 = require("../../system/app/consumer/consumer-queues");
|
|
18
|
-
const configuration_1 = require("../../system/common/configuration/configuration");
|
|
19
16
|
const worker_1 = require("../../system/common/worker/worker");
|
|
20
17
|
const async_1 = require("../../system/lib/async");
|
|
21
18
|
class WebsocketRateStreamWorker extends worker_1.Worker {
|
|
@@ -167,17 +164,4 @@ class WebsocketRateStreamWorker extends worker_1.Worker {
|
|
|
167
164
|
}
|
|
168
165
|
exports.WebsocketRateStreamWorker = WebsocketRateStreamWorker;
|
|
169
166
|
exports.default = WebsocketRateStreamWorker;
|
|
170
|
-
process.on('message', (payload) => {
|
|
171
|
-
const params = JSON.parse(payload);
|
|
172
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
173
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
174
|
-
if (err)
|
|
175
|
-
throw err;
|
|
176
|
-
else if (!client)
|
|
177
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
178
|
-
else {
|
|
179
|
-
new WebsocketRateStreamWorker(client, params, false).run();
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
167
|
//# sourceMappingURL=websocket-rate-stream.worker.js.map
|
|
@@ -5,7 +5,7 @@ const types_1 = require("../../../../types");
|
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
6
|
const message_1 = require("../message/message");
|
|
7
7
|
const events_1 = require("../../common/events");
|
|
8
|
-
const consumer_error_1 = require("./consumer.error");
|
|
8
|
+
const consumer_error_1 = require("./errors/consumer.error");
|
|
9
9
|
const redis_keys_1 = require("../../common/redis-keys/redis-keys");
|
|
10
10
|
const events_2 = require("events");
|
|
11
11
|
const power_manager_1 = require("../../common/power-manager/power-manager");
|
|
@@ -14,7 +14,6 @@ const consumer_message_rate_writer_1 = require("./consumer-message-rate-writer")
|
|
|
14
14
|
const base_1 = require("../../common/base");
|
|
15
15
|
const consumer_message_handler_1 = require("./consumer-message-handler");
|
|
16
16
|
const consumer_queues_1 = require("./consumer-queues");
|
|
17
|
-
const generic_error_1 = require("../../common/errors/generic.error");
|
|
18
17
|
const queue_manager_1 = require("../queue-manager/queue-manager");
|
|
19
18
|
const worker_pool_1 = require("../../common/worker/worker-runner/worker-pool");
|
|
20
19
|
const async_1 = require("../../lib/async");
|
|
@@ -25,6 +24,7 @@ const global_dead_lettered_time_series_1 = require("./consumer-time-series/globa
|
|
|
25
24
|
const queue_dead_lettered_time_series_1 = require("./consumer-time-series/queue-dead-lettered-time-series");
|
|
26
25
|
const consumer_acknowledged_time_series_1 = require("./consumer-time-series/consumer-acknowledged-time-series");
|
|
27
26
|
const consumer_dead_lettered_time_series_1 = require("./consumer-time-series/consumer-dead-lettered-time-series");
|
|
27
|
+
const message_handler_already_exists_error_1 = require("./errors/message-handler-already-exists.error");
|
|
28
28
|
class Consumer extends base_1.Base {
|
|
29
29
|
constructor() {
|
|
30
30
|
super();
|
|
@@ -194,7 +194,7 @@ class Consumer extends base_1.Base {
|
|
|
194
194
|
};
|
|
195
195
|
const r = this.addMessageHandler(handlerParams, usePriorityQueuing);
|
|
196
196
|
if (!r)
|
|
197
|
-
cb(new
|
|
197
|
+
cb(new message_handler_already_exists_error_1.MessageHandlerAlreadyExistsError(queueParams, usePriorityQueuing));
|
|
198
198
|
else {
|
|
199
199
|
if (this.isRunning())
|
|
200
200
|
this.runMessageHandler(handlerParams, (err) => {
|
|
@@ -210,9 +210,8 @@ class Consumer extends base_1.Base {
|
|
|
210
210
|
cancel(queue, usePriorityQueuing, cb) {
|
|
211
211
|
const queueParams = queue_manager_1.queueManager.getQueueParams(queue);
|
|
212
212
|
const handler = this.getMessageHandler(queueParams, usePriorityQueuing);
|
|
213
|
-
if (!handler)
|
|
214
|
-
cb(
|
|
215
|
-
}
|
|
213
|
+
if (!handler)
|
|
214
|
+
cb();
|
|
216
215
|
else {
|
|
217
216
|
this.removeMessageHandler(queueParams, usePriorityQueuing);
|
|
218
217
|
const handlerInstance = this.getMessageHandlerInstance(queueParams, usePriorityQueuing);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConsumerError = void 0;
|
|
4
|
-
const redis_smq_error_1 = require("
|
|
4
|
+
const redis_smq_error_1 = require("../../../common/errors/redis-smq.error");
|
|
5
5
|
class ConsumerError extends redis_smq_error_1.RedisSMQError {
|
|
6
6
|
}
|
|
7
7
|
exports.ConsumerError = ConsumerError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageHandlerAlreadyExistsError = void 0;
|
|
4
|
+
const consumer_error_1 = require("./consumer.error");
|
|
5
|
+
class MessageHandlerAlreadyExistsError extends consumer_error_1.ConsumerError {
|
|
6
|
+
constructor(queue, usingPriorityQueuing) {
|
|
7
|
+
super(`A message handler for ${usingPriorityQueuing ? 'priority ' : ''} queue [${JSON.stringify(queue)}] already exists`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MessageHandlerAlreadyExistsError = MessageHandlerAlreadyExistsError;
|
|
11
|
+
//# sourceMappingURL=message-handler-already-exists.error.js.map
|
|
@@ -5,9 +5,9 @@ export declare class QueueManagerFrontend {
|
|
|
5
5
|
private redisClient;
|
|
6
6
|
private logger;
|
|
7
7
|
constructor(redisClient: RedisClient);
|
|
8
|
-
clearQueueRateLimit(queue: TQueueParams, cb: ICallback<void>): void;
|
|
9
|
-
setQueueRateLimit(queue: TQueueParams, rateLimit: TQueueRateLimit, cb: ICallback<void>): void;
|
|
10
|
-
getQueueRateLimit(queue: TQueueParams, cb: ICallback<TQueueRateLimit>): void;
|
|
8
|
+
clearQueueRateLimit(queue: string | TQueueParams, cb: ICallback<void>): void;
|
|
9
|
+
setQueueRateLimit(queue: string | TQueueParams, rateLimit: TQueueRateLimit, cb: ICallback<void>): void;
|
|
10
|
+
getQueueRateLimit(queue: string | TQueueParams, cb: ICallback<TQueueRateLimit>): void;
|
|
11
11
|
deleteQueue(queue: string | TQueueParams, cb: ICallback<void>): void;
|
|
12
12
|
getNamespaceQueues(ns: string, cb: ICallback<TQueueParams[]>): void;
|
|
13
13
|
deleteNamespace(ns: string, cb: ICallback<void>): void;
|
|
@@ -12,13 +12,16 @@ class QueueManagerFrontend {
|
|
|
12
12
|
this.logger = (0, logger_1.getNamespacedLogger)('QueueManager');
|
|
13
13
|
}
|
|
14
14
|
clearQueueRateLimit(queue, cb) {
|
|
15
|
-
queue_manager_1.queueManager.
|
|
15
|
+
const queueParams = queue_manager_1.queueManager.getQueueParams(queue);
|
|
16
|
+
queue_manager_1.queueManager.clearQueueRateLimit(this.redisClient, queueParams, cb);
|
|
16
17
|
}
|
|
17
18
|
setQueueRateLimit(queue, rateLimit, cb) {
|
|
18
|
-
queue_manager_1.queueManager.
|
|
19
|
+
const queueParams = queue_manager_1.queueManager.getQueueParams(queue);
|
|
20
|
+
queue_manager_1.queueManager.setQueueRateLimit(this.redisClient, queueParams, rateLimit, cb);
|
|
19
21
|
}
|
|
20
22
|
getQueueRateLimit(queue, cb) {
|
|
21
|
-
queue_manager_1.queueManager.
|
|
23
|
+
const queueParams = queue_manager_1.queueManager.getQueueParams(queue);
|
|
24
|
+
queue_manager_1.queueManager.getQueueRateLimit(this.redisClient, queueParams, cb);
|
|
22
25
|
}
|
|
23
26
|
deleteQueue(queue, cb) {
|
|
24
27
|
const queueParams = queue_manager_1.queueManager.getQueueParams(queue);
|
|
@@ -9,19 +9,15 @@ export declare class WorkerRunner<WorkerParameters extends TWorkerParameters = T
|
|
|
9
9
|
private readonly powerManager;
|
|
10
10
|
private readonly ticker;
|
|
11
11
|
private readonly lockManager;
|
|
12
|
-
private readonly workerThreads;
|
|
13
12
|
private readonly redisClient;
|
|
14
13
|
private readonly logger;
|
|
15
14
|
private readonly workerPool;
|
|
16
15
|
private initialized;
|
|
17
|
-
constructor(redisClient: RedisClient, workersDir: string, keyLock: string, workerParameters: WorkerParameters, workerPool
|
|
16
|
+
constructor(redisClient: RedisClient, workersDir: string, keyLock: string, workerParameters: WorkerParameters, workerPool: WorkerPool);
|
|
18
17
|
private onTick;
|
|
19
|
-
private onProcessExit;
|
|
20
18
|
private init;
|
|
21
19
|
private addToWorkerPool;
|
|
22
20
|
private createWorkerInstance;
|
|
23
|
-
private forkWorkerThread;
|
|
24
|
-
private shutdownWorkerThreads;
|
|
25
21
|
private clearWorkerPool;
|
|
26
22
|
private stopTicker;
|
|
27
23
|
private releaseLock;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkerRunner = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
const fs_1 = require("fs");
|
|
7
6
|
const power_manager_1 = require("../../power-manager/power-manager");
|
|
8
|
-
const worker_runner_error_1 = require("./worker-runner.error");
|
|
9
7
|
const events_1 = require("events");
|
|
10
8
|
const ticker_1 = require("../../ticker/ticker");
|
|
11
9
|
const lock_manager_1 = require("../../lock-manager/lock-manager");
|
|
@@ -17,8 +15,6 @@ const async_1 = require("../../../lib/async");
|
|
|
17
15
|
class WorkerRunner extends events_1.EventEmitter {
|
|
18
16
|
constructor(redisClient, workersDir, keyLock, workerParameters, workerPool) {
|
|
19
17
|
super();
|
|
20
|
-
this.workerThreads = [];
|
|
21
|
-
this.workerPool = null;
|
|
22
18
|
this.initialized = false;
|
|
23
19
|
this.onTick = () => {
|
|
24
20
|
this.lockManager.acquireLock((err, locked) => {
|
|
@@ -49,11 +45,6 @@ class WorkerRunner extends events_1.EventEmitter {
|
|
|
49
45
|
this.ticker.nextTick();
|
|
50
46
|
});
|
|
51
47
|
};
|
|
52
|
-
this.onProcessExit = () => {
|
|
53
|
-
this.workerThreads.forEach((i) => i.kill());
|
|
54
|
-
if (this.workerPool)
|
|
55
|
-
this.workerPool.clear(() => void 0);
|
|
56
|
-
};
|
|
57
48
|
this.init = (cb) => {
|
|
58
49
|
(0, fs_1.readdir)(this.workersDir, undefined, (err, reply) => {
|
|
59
50
|
if (err)
|
|
@@ -61,12 +52,7 @@ class WorkerRunner extends events_1.EventEmitter {
|
|
|
61
52
|
else {
|
|
62
53
|
(0, async_1.each)(reply !== null && reply !== void 0 ? reply : [], (filename, _, done) => {
|
|
63
54
|
if (filename.match(/\.worker\.js$/)) {
|
|
64
|
-
|
|
65
|
-
this.addToWorkerPool(filename, done);
|
|
66
|
-
else {
|
|
67
|
-
this.forkWorkerThread(filename);
|
|
68
|
-
done();
|
|
69
|
-
}
|
|
55
|
+
this.addToWorkerPool(filename, done);
|
|
70
56
|
}
|
|
71
57
|
else
|
|
72
58
|
done();
|
|
@@ -96,31 +82,6 @@ class WorkerRunner extends events_1.EventEmitter {
|
|
|
96
82
|
})
|
|
97
83
|
.catch(cb);
|
|
98
84
|
};
|
|
99
|
-
this.forkWorkerThread = (filename) => {
|
|
100
|
-
const filepath = (0, path_1.join)(this.workersDir, filename);
|
|
101
|
-
const thread = (0, child_process_1.fork)(filepath);
|
|
102
|
-
thread.on('error', (err) => {
|
|
103
|
-
if (this.powerManager.isGoingUp() || this.powerManager.isRunning()) {
|
|
104
|
-
this.emit(events_2.events.ERROR, err);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
thread.on('exit', (code, signal) => {
|
|
108
|
-
if (this.powerManager.isGoingUp() || this.powerManager.isRunning()) {
|
|
109
|
-
this.emit(events_2.events.ERROR, new worker_runner_error_1.WorkerRunnerError(`Thread [${filepath}] exited with code ${code} and signal ${signal}`));
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
thread.send(JSON.stringify(this.workerParameters));
|
|
113
|
-
this.workerThreads.push(thread);
|
|
114
|
-
};
|
|
115
|
-
this.shutdownWorkerThreads = (cb) => {
|
|
116
|
-
const thread = this.workerThreads.pop();
|
|
117
|
-
if (thread) {
|
|
118
|
-
thread.once('exit', () => this.shutdownWorkerThreads(cb));
|
|
119
|
-
thread.kill('SIGHUP');
|
|
120
|
-
}
|
|
121
|
-
else
|
|
122
|
-
cb();
|
|
123
|
-
};
|
|
124
85
|
this.clearWorkerPool = (cb) => {
|
|
125
86
|
if (this.workerPool)
|
|
126
87
|
this.workerPool.clear(cb);
|
|
@@ -136,20 +97,13 @@ class WorkerRunner extends events_1.EventEmitter {
|
|
|
136
97
|
};
|
|
137
98
|
this.run = () => {
|
|
138
99
|
this.powerManager.goingUp();
|
|
139
|
-
process.once('exit', this.onProcessExit);
|
|
140
100
|
this.ticker.nextTick();
|
|
141
101
|
this.powerManager.commit();
|
|
142
102
|
this.emit(events_2.events.UP);
|
|
143
103
|
};
|
|
144
104
|
this.quit = (cb) => {
|
|
145
105
|
this.powerManager.goingDown();
|
|
146
|
-
(0, async_1.waterfall)([
|
|
147
|
-
this.stopTicker,
|
|
148
|
-
this.shutdownWorkerThreads,
|
|
149
|
-
this.clearWorkerPool,
|
|
150
|
-
this.releaseLock,
|
|
151
|
-
], () => {
|
|
152
|
-
process.removeListener('exit', this.onProcessExit);
|
|
106
|
+
(0, async_1.waterfall)([this.stopTicker, this.clearWorkerPool, this.releaseLock], () => {
|
|
153
107
|
this.initialized = false;
|
|
154
108
|
this.powerManager.commit();
|
|
155
109
|
this.emit(events_2.events.DOWN);
|
|
@@ -163,9 +117,7 @@ class WorkerRunner extends events_1.EventEmitter {
|
|
|
163
117
|
this.logger = (0, logger_1.getNamespacedLogger)(this.constructor.name);
|
|
164
118
|
this.lockManager = new lock_manager_1.LockManager(redisClient, keyLock, 10000, false);
|
|
165
119
|
this.ticker = new ticker_1.Ticker(this.onTick, 1000);
|
|
166
|
-
|
|
167
|
-
this.workerPool = workerPool;
|
|
168
|
-
}
|
|
120
|
+
this.workerPool = workerPool;
|
|
169
121
|
}
|
|
170
122
|
}
|
|
171
123
|
exports.WorkerRunner = WorkerRunner;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DelayWorker = void 0;
|
|
4
|
-
const redis_client_1 = require("../common/redis-client/redis-client");
|
|
5
4
|
const redis_keys_1 = require("../common/redis-keys/redis-keys");
|
|
6
|
-
const empty_callback_reply_error_1 = require("../common/errors/empty-callback-reply.error");
|
|
7
5
|
const message_1 = require("../app/message/message");
|
|
8
6
|
const broker_1 = require("../common/broker/broker");
|
|
9
7
|
const worker_1 = require("../common/worker/worker");
|
|
10
|
-
const configuration_1 = require("../common/configuration/configuration");
|
|
11
8
|
const async_1 = require("../lib/async");
|
|
12
9
|
class DelayWorker extends worker_1.Worker {
|
|
13
10
|
constructor(redisClient, params, managed) {
|
|
@@ -46,16 +43,4 @@ class DelayWorker extends worker_1.Worker {
|
|
|
46
43
|
}
|
|
47
44
|
exports.DelayWorker = DelayWorker;
|
|
48
45
|
exports.default = DelayWorker;
|
|
49
|
-
process.on('message', (payload) => {
|
|
50
|
-
const params = JSON.parse(payload);
|
|
51
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
52
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
53
|
-
if (err)
|
|
54
|
-
throw err;
|
|
55
|
-
else if (!client)
|
|
56
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
57
|
-
else
|
|
58
|
-
new DelayWorker(client, params, false).run();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
46
|
//# sourceMappingURL=delay.worker.js.map
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HeartbeatMonitorWorker = void 0;
|
|
4
4
|
const consumer_heartbeat_1 = require("../app/consumer/consumer-heartbeat");
|
|
5
|
-
const redis_client_1 = require("../common/redis-client/redis-client");
|
|
6
|
-
const empty_callback_reply_error_1 = require("../common/errors/empty-callback-reply.error");
|
|
7
5
|
const worker_1 = require("../common/worker/worker");
|
|
8
|
-
const configuration_1 = require("../common/configuration/configuration");
|
|
9
6
|
const async_1 = require("../lib/async");
|
|
10
7
|
class HeartbeatMonitorWorker extends worker_1.Worker {
|
|
11
8
|
constructor() {
|
|
@@ -22,16 +19,4 @@ class HeartbeatMonitorWorker extends worker_1.Worker {
|
|
|
22
19
|
}
|
|
23
20
|
exports.HeartbeatMonitorWorker = HeartbeatMonitorWorker;
|
|
24
21
|
exports.default = HeartbeatMonitorWorker;
|
|
25
|
-
process.on('message', (payload) => {
|
|
26
|
-
const params = JSON.parse(payload);
|
|
27
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
28
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
29
|
-
if (err)
|
|
30
|
-
throw err;
|
|
31
|
-
else if (!client)
|
|
32
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
33
|
-
else
|
|
34
|
-
new HeartbeatMonitorWorker(client, params, false).run();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
22
|
//# sourceMappingURL=heartbeat-monitor.worker.js.map
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RequeueWorker = void 0;
|
|
4
|
-
const redis_client_1 = require("../common/redis-client/redis-client");
|
|
5
4
|
const redis_keys_1 = require("../common/redis-keys/redis-keys");
|
|
6
5
|
const message_1 = require("../app/message/message");
|
|
7
|
-
const empty_callback_reply_error_1 = require("../common/errors/empty-callback-reply.error");
|
|
8
6
|
const panic_error_1 = require("../common/errors/panic.error");
|
|
9
7
|
const worker_1 = require("../common/worker/worker");
|
|
10
|
-
const configuration_1 = require("../common/configuration/configuration");
|
|
11
8
|
const async_1 = require("../lib/async");
|
|
12
9
|
class RequeueWorker extends worker_1.Worker {
|
|
13
10
|
constructor(redisClient, params, managed) {
|
|
@@ -55,16 +52,4 @@ class RequeueWorker extends worker_1.Worker {
|
|
|
55
52
|
}
|
|
56
53
|
exports.RequeueWorker = RequeueWorker;
|
|
57
54
|
exports.default = RequeueWorker;
|
|
58
|
-
process.on('message', (payload) => {
|
|
59
|
-
const params = JSON.parse(payload);
|
|
60
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
61
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
62
|
-
if (err)
|
|
63
|
-
throw err;
|
|
64
|
-
else if (!client)
|
|
65
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
66
|
-
else
|
|
67
|
-
new RequeueWorker(client, params, false).run();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
55
|
//# sourceMappingURL=requeue.worker.js.map
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ScheduleWorker = void 0;
|
|
4
4
|
const redis_keys_1 = require("../common/redis-keys/redis-keys");
|
|
5
|
-
const redis_client_1 = require("../common/redis-client/redis-client");
|
|
6
5
|
const empty_callback_reply_error_1 = require("../common/errors/empty-callback-reply.error");
|
|
7
6
|
const message_1 = require("../app/message/message");
|
|
8
7
|
const lua_scripts_1 = require("../common/redis-client/lua-scripts");
|
|
9
8
|
const worker_1 = require("../common/worker/worker");
|
|
10
|
-
const configuration_1 = require("../common/configuration/configuration");
|
|
11
9
|
const async_1 = require("../lib/async");
|
|
12
10
|
class ScheduleWorker extends worker_1.Worker {
|
|
13
11
|
constructor() {
|
|
@@ -88,16 +86,4 @@ class ScheduleWorker extends worker_1.Worker {
|
|
|
88
86
|
}
|
|
89
87
|
exports.ScheduleWorker = ScheduleWorker;
|
|
90
88
|
exports.default = ScheduleWorker;
|
|
91
|
-
process.on('message', (payload) => {
|
|
92
|
-
const params = JSON.parse(payload);
|
|
93
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
94
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
95
|
-
if (err)
|
|
96
|
-
throw err;
|
|
97
|
-
else if (!client)
|
|
98
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
99
|
-
else
|
|
100
|
-
new ScheduleWorker(client, params, false).run();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
89
|
//# sourceMappingURL=schedule.worker.js.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimeSeriesWorker = void 0;
|
|
4
|
-
const redis_client_1 = require("../common/redis-client/redis-client");
|
|
5
|
-
const empty_callback_reply_error_1 = require("../common/errors/empty-callback-reply.error");
|
|
6
4
|
const worker_1 = require("../common/worker/worker");
|
|
7
|
-
const configuration_1 = require("../common/configuration/configuration");
|
|
8
5
|
const queue_manager_1 = require("../app/queue-manager/queue-manager");
|
|
9
6
|
const async_1 = require("../lib/async");
|
|
10
7
|
const queue_acknowledged_time_series_1 = require("../app/consumer/consumer-time-series/queue-acknowledged-time-series");
|
|
@@ -82,16 +79,4 @@ class TimeSeriesWorker extends worker_1.Worker {
|
|
|
82
79
|
}
|
|
83
80
|
exports.TimeSeriesWorker = TimeSeriesWorker;
|
|
84
81
|
exports.default = TimeSeriesWorker;
|
|
85
|
-
process.on('message', (payload) => {
|
|
86
|
-
const params = JSON.parse(payload);
|
|
87
|
-
(0, configuration_1.setConfiguration)(params.config);
|
|
88
|
-
redis_client_1.RedisClient.getNewInstance((err, client) => {
|
|
89
|
-
if (err)
|
|
90
|
-
throw err;
|
|
91
|
-
else if (!client)
|
|
92
|
-
throw new empty_callback_reply_error_1.EmptyCallbackReplyError();
|
|
93
|
-
else
|
|
94
|
-
new TimeSeriesWorker(client, params, false).run();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
82
|
//# sourceMappingURL=time-series.worker.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redis-smq",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"description": "A simple high-performance Redis message queue for Node.js.",
|
|
5
5
|
"author": "Weyoss <weyoss@protonmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"koa-bodyparser": "4.3.0",
|
|
50
50
|
"lodash": "4.17.21",
|
|
51
51
|
"redis": "3.1.2",
|
|
52
|
-
"redis-smq-monitor": "6.5.
|
|
52
|
+
"redis-smq-monitor": "6.5.3",
|
|
53
53
|
"reflect-metadata": "0.1.13",
|
|
54
54
|
"socket.io": "4.2.0",
|
|
55
55
|
"stoppable": "1.1.0",
|