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

clusterhub

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clusterhub - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

7

lib/fork.js

@@ -40,3 +40,3 @@ const cluster = require('cluster');

const hub = hubs.get(msg.hub);
let db, result, fn;
let db, result;
parseFuncs(hub, msg, worker);

@@ -80,6 +80,3 @@ switch (msg.cmd) {

case commands.FN:
fn = hub._funcs.get(msg.key);
if (fn) {
fn(...msg.args);
}
hub._callFunc(msg);
break;

@@ -86,0 +83,0 @@

@@ -21,2 +21,3 @@ const cluster = require('cluster');

this._funcs = new Map();
this._funcsHistory = new Set();
this._maxFuncs = 100;

@@ -144,5 +145,2 @@

funcs.push({ i, key: this._keyFunc(this._funcs, arg) });
if (this._funcs.size > this._maxFuncs) {
this._funcs.delete(this._funcs.keys().next().value);
}
}

@@ -154,2 +152,21 @@ }

/**
* Calls a function that was called by another process.
*
* @param {Object} msg
*/
_callFunc(msg) {
const fn = this._funcs.get(msg.key);
if (fn) {
fn(...msg.args);
this._funcsHistory.delete(msg.key);
this._funcsHistory.add(msg.key);
if (this._funcsHistory.size > this._maxFuncs) {
const key = this._funcsHistory.keys().next().value;
this._funcs.delete(key);
this._funcsHistory.delete(key);
}
}
}
/**
* Emits event to all workers and the master in the hub.

@@ -280,7 +297,8 @@ *

this.removeAllListeners();
this._funcs = new Map();
this._funcs.clear();
this._funcsHistory.clear();
if (isMaster) {
this._db.die();
} else {
this._callbacks = new Map();
this._callbacks.clear();
}

@@ -287,0 +305,0 @@ }

@@ -37,6 +37,3 @@ const commands = require('./globals').commands;

case commands.FN:
fn = hub._funcs.get(msg.key);
if (fn) {
fn(...msg.args);
}
hub._callFunc(msg);
break;

@@ -43,0 +40,0 @@ }

@@ -11,3 +11,3 @@ {

],
"version": "1.0.0",
"version": "1.0.1",
"repository": {

@@ -14,0 +14,0 @@ "type": "git",

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