Comparing version 0.6.1 to 0.6.2
@@ -432,2 +432,30 @@ var os = require('os'), | ||
/** | ||
* Broadcast event to all workers. | ||
* @method | ||
* @param {String} event of called command in the worker | ||
* @param {*} ...args | ||
* @public | ||
*/ | ||
Master.prototype.broadcastEventToAll = function() { | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
this.forEach(function(worker) { | ||
if (worker.ready) { | ||
worker.broadcastEvent.apply(worker, args); | ||
} | ||
}); | ||
}; | ||
/** | ||
* Emit event on master and all workers in "ready" state. | ||
* @method | ||
* @param {String} event of called command in the worker | ||
* @param {*} ...args | ||
* @public | ||
*/ | ||
Master.prototype.emitToAll = function() { | ||
this.emit.apply(this, arguments); | ||
this.broadcastEventToAll.apply(this, arguments); | ||
}; | ||
/** | ||
* @event Master#shutdown | ||
@@ -434,0 +462,0 @@ */ |
@@ -50,2 +50,3 @@ /** | ||
worker : { | ||
broadcastMasterEvent : 'core.worker.broadcastMasterEvent', | ||
applyForeignProperties : 'core.worker.applyForeignProperties' | ||
@@ -59,2 +60,2 @@ }, | ||
module.exports = RPC; | ||
module.exports = RPC; |
@@ -630,2 +630,6 @@ var cluster = require('cluster'), | ||
WorkerWrapper.prototype.broadcastEvent = function() { | ||
this.remoteCall(RPC.fns.worker.broadcastMasterEvent, Array.prototype.slice.call(arguments, 0)); | ||
}; | ||
module.exports = WorkerWrapper; |
@@ -42,5 +42,14 @@ var cluster = require('cluster'), | ||
this.registerRemoteCommand(RPC.fns.worker.applyForeignProperties, this.applyForeignProperties.bind(this)); | ||
this.registerRemoteCommand(RPC.fns.worker.broadcastMasterEvent, this.broadcastMasterEvent.bind(this)); | ||
}); | ||
/** | ||
* Emit an event received from the master as 'master <event>'. | ||
*/ | ||
Worker.prototype.broadcastMasterEvent = function(proc, emitArgs) { | ||
var args = [ 'master ' + emitArgs[0] ].concat(emitArgs.slice(1)); | ||
this.emit.apply(this, args); | ||
}; | ||
/** | ||
* Transmit worker event to master, which plays as relay, | ||
@@ -47,0 +56,0 @@ * retransmitting it as 'worker <event>' to all master-side listeners. |
{ | ||
"name" : "luster", | ||
"version" : "0.6.1", | ||
"version" : "0.6.2", | ||
"description" : "Node.js cluster wrapper", | ||
@@ -5,0 +5,0 @@ "main" : "./lib/luster.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
84723
2087
0