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

luster

Package Overview
Dependencies
Maintainers
6
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

luster - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

3

lib/rpc.js

@@ -51,3 +51,4 @@ /**

broadcastMasterEvent: 'core.worker.broadcastMasterEvent',
applyForeignProperties: 'core.worker.applyForeignProperties'
applyForeignProperties: 'core.worker.applyForeignProperties',
suspend: 'core.worker.suspend'
},

@@ -54,0 +55,0 @@ master: {

@@ -424,3 +424,9 @@ const cluster = require('cluster'),

if (this.isRunning()) {
this._worker.disconnect();
this.remoteCallWithCallback({
command: RPC.fns.worker.suspend,
callback: () => {
this._worker.disconnect();
}
});
this._scheduleForceStop();

@@ -427,0 +433,0 @@ }

@@ -37,2 +37,6 @@ const cluster = require('cluster'),

this.registerRemoteCommand(RPC.fns.worker.broadcastMasterEvent, this.broadcastMasterEvent.bind(this));
this._suspendFunctions = [];
this.registerRemoteCommandWithCallback(RPC.fns.worker.suspend, this._suspend.bind(this));
this._suspendPromise = null;
}

@@ -165,2 +169,33 @@

}
/**
* @callback SuspendFunction
* @returns void|Promise<void>
*/
/**
* This adds new function that will be called before stopping worker.
* Worker will wait for returned promise to resolve and then report to master it suspended successfully.
* Rejects will emit 'error' event, no report to master will happen.
* All suspend functions are called simultaneously.
* Suspend function will not be called more than once.
* @param {SuspendFunction} func
* @public
*/
registerSuspendFunction(func) {
this._suspendFunctions.push(func);
}
_suspend(callback) {
if (!this._suspendPromise) {
this._suspendPromise = Promise.all(this._suspendFunctions.map(func => func()));
}
this._suspendPromise.then(
callback,
error => {
this.emit('error', error);
}
);
}
}

@@ -167,0 +202,0 @@

{
"name": "luster",
"version": "2.0.2",
"version": "2.1.0",
"description": "Node.js cluster wrapper",

@@ -47,2 +47,3 @@ "main": "./lib/luster.js",

"mocha": "^3.1.2",
"p-event": "^4.1.0",
"sinon": "^1.17.6",

@@ -49,0 +50,0 @@ "sinon-chai": "^2.8.0"

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