@imqueue/core 2.0.6 → 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 CHANGED
@@ -1,9 +1,5 @@
1
1
  # I Message Queue (@imqueue/core)
2
2
 
3
- [![Build Status](https://img.shields.io/github/actions/workflow/status/imqueue/core/build.yml)](https://github.com/imqueue/core)
4
- [![codebeat badge](https://codebeat.co/badges/b7685cb5-b290-47de-80e1-bde3e0582355)](https://codebeat.co/projects/github-com-imqueue-core-master)
5
- [![Coverage Status](https://coveralls.io/repos/github/imqueue/core/badge.svg?branch=master)](https://coveralls.io/github/imqueue/core?branch=master)
6
- [![Known Vulnerabilities](https://snyk.io/test/github/imqueue/core/badge.svg?targetFile=package.json)](https://snyk.io/test/github/imqueue/core?targetFile=package.json)
7
3
  [![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://rawgit.com/imqueue/core/master/LICENSE)
8
4
 
9
5
  Simple JSON-based messaging queue for inter service communication
package/debug.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ declare class DebugGetter {
2
+ name: string;
3
+ static propertiesMap: Record<string, string>;
4
+ private get property();
5
+ private set property(value);
6
+ constructor(name: string);
7
+ addProperty(value: string): void;
8
+ removeProperty(): void;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/core",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Simple JSON-based messaging queue for inter service communication",
5
5
  "keywords": [
6
6
  "message-queue",
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
  /**
@@ -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: 1000,
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
- server.timestamp = Date.now();
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
- const timerId = setTimeout(() => {
129
- const existing = cluster.find(server, true);
130
- if (!existing || existing.timer !== timerId) {
131
- return;
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 delta = now - existing.timestamp;
141
- const currentTimeout = (existing.timeout || 0) + correction;
142
- if (delta >= currentTimeout) {
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