Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cluster-client

Package Overview
Dependencies
Maintainers
14
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster-client - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

6

History.md
3.2.0 / 2022-10-18
==================
**features**
* [[`c9f389d`](http://github.com/node-modules/cluster-client/commit/c9f389d277abf75a5b3274626b326b6642b208f1)] - feat: impl subscribeTimeout (#56) (killa <<killa123@126.com>>)
3.1.1 / 2022-06-22

@@ -3,0 +9,0 @@ ==================

2

lib/api_client.js

@@ -36,3 +36,3 @@ 'use strict';

if (is.function(this._client.close)) {
return this._client.close();
return this._client.close().then(() => cluster.close(this._client));
}

@@ -39,0 +39,0 @@ return cluster.close(this._client);

@@ -16,3 +16,3 @@ 'use strict';

* - {Transcode} transcode - serialze / deserialze methods
* @constructor
* @class
*/

@@ -19,0 +19,0 @@ constructor(options) {

@@ -19,3 +19,4 @@ 'use strict';

* - {Number} responseTimeout - the timeout
* @constructor
* - {Number} subscribeTimeout - the first subscribe callback timeout
* @class
*/

@@ -31,2 +32,3 @@ constructor(options) {

this._closeByUser = false;
this._subscribeTimeoutListeners = new Map();

@@ -112,5 +114,37 @@ this.on('request', req => this._handleRequest(req));

_clearSubscribeTimeout(key) {
if (!this._subscribeTimeoutListeners.has(key)) {
return;
}
const timeout = this._subscribeTimeoutListeners.get(key);
clearTimeout(timeout);
this._subscribeTimeoutListeners.delete(key);
}
_setSubscribeTimeout(key) {
this._clearSubscribeTimeout(key);
const start = Date.now();
const subscribeTimeout = this.options.subscribeTimeout;
const timeout = setTimeout(() => {
const error = new Error(`subscribe timeout for ${key}, cost: ${Date.now() - start}ms, expect is ${subscribeTimeout}ms`);
this.emit('error', error);
}, subscribeTimeout);
this._subscribeTimeoutListeners.set(key, timeout);
}
_listenSubscribeTimeout(key) {
this._setSubscribeTimeout(key);
const dataListener = () => {
this.removeListener(key, dataListener);
this._clearSubscribeTimeout(key);
};
this.on(key, dataListener);
}
subscribe(reg, listener) {
const key = this.formatKey(reg);
this.on(key, listener);
if (this.options.subscribeTimeout) {
this._listenSubscribeTimeout(key);
}

@@ -117,0 +151,0 @@ // no need duplicate subscribe

@@ -15,3 +15,3 @@ 'use strict';

maxWaitTime: 30000,
connectTimeout: parseInt(process.env.NODE_CLUSTER_CLIENT_CONNECT_TIMEOUT) || 10000,
connectTimeout: parseInt(process.env.NODE_CLUSTER_CLIENT_CONNECT_TIMEOUT) || 10000,
responseTimeout: 3000,

@@ -47,3 +47,3 @@ heartbeatInterval: 20000,

* - {Number} [maxWaitTime|30000] - leader startup max time (ONLY effective on isLeader is true)
* @constructor
* @class
*/

@@ -50,0 +50,0 @@ constructor(clientClass, options) {

@@ -24,3 +24,3 @@ 'use strict';

* - {Function} createRealClient - to create the real client
* @constructor
* @class
*/

@@ -27,0 +27,0 @@ constructor(options) {

@@ -42,3 +42,3 @@ 'use strict';

* - @param {Buffer} data - app data
* @constructor
* @class
*/

@@ -45,0 +45,0 @@ constructor(options) {

@@ -72,3 +72,3 @@ 'use strict';

*
* @constructor
* @class
* @param {Object} options

@@ -75,0 +75,0 @@ * - {net.Server} server - the server

@@ -36,3 +36,3 @@ 'use strict';

* - {Function} createRealClient - to create the real client instance
* @constructor
* @class
*/

@@ -39,0 +39,0 @@ constructor(options) {

{
"name": "cluster-client",
"version": "3.1.1",
"version": "3.2.0",
"description": "Sharing Connection among Multi-Process Nodejs",

@@ -13,3 +13,3 @@ "main": "./index.js",

"lint": "eslint . --ext .js",
"cov": "TEST_TIMEOUT=20000 egg-bin cov",
"cov": "egg-bin cov --timeout 20000",
"test": "npm run lint && npm run test-local",

@@ -71,4 +71,4 @@ "test-local": "egg-bin test",

"ci": {
"version": "8, 10"
"version": "8, 10, 12, 14, 16"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc