@imqueue/core 2.0.5 → 2.0.8
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/README.md +0 -4
- package/package.json +17 -17
- package/src/RedisQueue.js +3 -0
- package/src/UDPClusterManager.js +15 -26
package/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# I Message Queue (@imqueue/core)
|
|
2
2
|
|
|
3
|
-
[](https://github.com/imqueue/core)
|
|
4
|
-
[](https://codebeat.co/projects/github-com-imqueue-core-master)
|
|
5
|
-
[](https://coveralls.io/github/imqueue/core?branch=master)
|
|
6
|
-
[](https://snyk.io/test/github/imqueue/core?targetFile=package.json)
|
|
7
3
|
[](https://rawgit.com/imqueue/core/master/LICENSE)
|
|
8
4
|
|
|
9
5
|
Simple JSON-based messaging queue for inter service communication
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Simple JSON-based messaging queue for inter service communication",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"message-queue",
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"json-message"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
+
"benchmark": "node benchmark -c $(( $(nproc) - 2 )) -m 100000",
|
|
14
15
|
"prepare": "./node_modules/.bin/tsc",
|
|
15
|
-
"test": "./node_modules/.bin/tsc && ./node_modules/.bin/nyc mocha && ./node_modules/.bin/nyc report --reporter=text-lcov
|
|
16
|
+
"test": "./node_modules/.bin/tsc && ./node_modules/.bin/nyc mocha && ./node_modules/.bin/nyc report --reporter=text-lcov",
|
|
16
17
|
"test-fast": "./node_modules/.bin/tsc && ./node_modules/.bin/nyc mocha && /usr/bin/env node -e \"import('open').then(open => open.default('file://`pwd`/coverage/index.html', { wait: false }))\"",
|
|
17
18
|
"test-local": "export COVERALLS_REPO_TOKEN=$IMQ_COVERALLS_TOKEN && npm test && /usr/bin/env node -e \"import('open').then(open => open.default('https://coveralls.io/github/imqueue/imq', { wait: false }))\"",
|
|
18
19
|
"test-dev": "npm run test && npm run clean-js && npm run clean-typedefs && npm run clean-maps",
|
|
@@ -37,37 +38,36 @@
|
|
|
37
38
|
"author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
|
|
38
39
|
"license": "GPL-3.0-only",
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"ioredis": "^5.
|
|
41
|
+
"ioredis": "^5.7.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@eslint/js": "^9.
|
|
44
|
+
"@eslint/js": "^9.33.0",
|
|
44
45
|
"@types/chai": "^5.2.2",
|
|
45
46
|
"@types/eslint__eslintrc": "^2.1.2",
|
|
46
47
|
"@types/mocha": "^10.0.0",
|
|
47
48
|
"@types/mock-require": "^3.0.0",
|
|
48
|
-
"@types/node": "^24.
|
|
49
|
+
"@types/node": "^24.2.1",
|
|
49
50
|
"@types/sinon": "^17.0.4",
|
|
50
51
|
"@types/yargs": "^17.0.33",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
52
|
-
"@typescript-eslint/parser": "^8.
|
|
53
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
54
|
-
"chai": "^5.2.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"eslint-plugin-jsdoc": "^51.3.1",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
53
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
54
|
+
"@typescript-eslint/typescript-estree": "^8.39.0",
|
|
55
|
+
"chai": "^5.2.1",
|
|
56
|
+
"coveralls-next": "^5.0.0",
|
|
57
|
+
"eslint": "^9.33.0",
|
|
58
|
+
"eslint-plugin-jsdoc": "^52.0.4",
|
|
59
59
|
"mocha": "^11.7.1",
|
|
60
60
|
"mocha-lcov-reporter": "^1.3.0",
|
|
61
61
|
"mock-require": "^3.0.3",
|
|
62
62
|
"nyc": "^17.1.0",
|
|
63
|
-
"open": "^10.
|
|
63
|
+
"open": "^10.2.0",
|
|
64
64
|
"reflect-metadata": "^0.2.2",
|
|
65
65
|
"sinon": "^21.0.0",
|
|
66
66
|
"source-map-support": "^0.5.21",
|
|
67
67
|
"ts-node": "^10.9.2",
|
|
68
|
-
"typedoc": "^0.28.
|
|
69
|
-
"typescript": "^5.
|
|
70
|
-
"yargs": "^
|
|
68
|
+
"typedoc": "^0.28.9",
|
|
69
|
+
"typescript": "^5.9.2",
|
|
70
|
+
"yargs": "^18.0.0"
|
|
71
71
|
},
|
|
72
72
|
"main": "index.js",
|
|
73
73
|
"typescript": {
|
package/src/RedisQueue.js
CHANGED
|
@@ -648,6 +648,9 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
648
648
|
}
|
|
649
649
|
const rx = new RegExp(`\\bname=${this.options.prefix}:[\\S]+?:watcher:`);
|
|
650
650
|
const list = await this.writer.client('LIST');
|
|
651
|
+
if (!list || !list.split) {
|
|
652
|
+
return 0;
|
|
653
|
+
}
|
|
651
654
|
return list.split(/\r?\n/).filter(client => rx.test(client)).length;
|
|
652
655
|
}
|
|
653
656
|
/**
|
package/src/UDPClusterManager.js
CHANGED
|
@@ -12,7 +12,7 @@ var MessageType;
|
|
|
12
12
|
exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = {
|
|
13
13
|
broadcastPort: 63000,
|
|
14
14
|
broadcastAddress: '255.255.255.255',
|
|
15
|
-
aliveTimeoutCorrection:
|
|
15
|
+
aliveTimeoutCorrection: 2000,
|
|
16
16
|
};
|
|
17
17
|
const LOCALHOST_ADDRESSES = [
|
|
18
18
|
'localhost',
|
|
@@ -111,41 +111,27 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
|
|
|
111
111
|
timeout: parseFloat(timeout) * 1000,
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
static serverAliveWait(cluster, server, aliveTimeoutCorrection, message) {
|
|
114
|
+
static serverAliveWait(cluster, server, aliveTimeoutCorrection = 0, message) {
|
|
115
115
|
if (server.timer) {
|
|
116
116
|
clearTimeout(server.timer);
|
|
117
117
|
server.timer = undefined;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
if (message) {
|
|
121
|
-
server.timeout = message.timeout;
|
|
122
|
-
}
|
|
123
|
-
const correction = aliveTimeoutCorrection || 0;
|
|
124
|
-
const timeout = (server.timeout || 0) + correction;
|
|
119
|
+
const timeout = ((message === null || message === void 0 ? void 0 : message.timeout) || 0) + aliveTimeoutCorrection;
|
|
125
120
|
if (timeout <= 0) {
|
|
126
121
|
return;
|
|
127
122
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const now = Date.now();
|
|
134
|
-
if (!existing.timestamp) {
|
|
135
|
-
clearTimeout(existing.timer);
|
|
136
|
-
existing.timer = undefined;
|
|
137
|
-
cluster.remove(existing);
|
|
123
|
+
server.timeout = timeout;
|
|
124
|
+
server.timestamp = Date.now();
|
|
125
|
+
server.timer = setTimeout(() => {
|
|
126
|
+
const entry = cluster.find(server, true);
|
|
127
|
+
if (typeof (entry === null || entry === void 0 ? void 0 : entry.timestamp) !== 'number') {
|
|
138
128
|
return;
|
|
139
129
|
}
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
clearTimeout(existing.timer);
|
|
144
|
-
existing.timer = undefined;
|
|
145
|
-
cluster.remove(existing);
|
|
130
|
+
const elapsed = Date.now() - entry.timestamp;
|
|
131
|
+
if (elapsed >= timeout) {
|
|
132
|
+
cluster.remove(entry);
|
|
146
133
|
}
|
|
147
134
|
}, timeout);
|
|
148
|
-
server.timer = timerId;
|
|
149
135
|
}
|
|
150
136
|
/**
|
|
151
137
|
* Destroys the UDPClusterManager by closing all opened network connections
|
|
@@ -166,7 +152,10 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
|
|
|
166
152
|
if (typeof socket.close === 'function') {
|
|
167
153
|
socket.removeAllListeners();
|
|
168
154
|
socket.close(() => {
|
|
169
|
-
|
|
155
|
+
// unref may be missing or not a function on mocked sockets
|
|
156
|
+
if (socket && typeof socket.unref === 'function') {
|
|
157
|
+
socket.unref();
|
|
158
|
+
}
|
|
170
159
|
if (socketKey
|
|
171
160
|
&& UDPClusterManager.sockets[socketKey]) {
|
|
172
161
|
delete UDPClusterManager.sockets[socketKey];
|