cluster-emitter
Advanced tools
Comparing version 0.5.0-SNAPSHOT.1387314416214 to 0.5.0-SNAPSHOT.1388501015412
@@ -241,2 +241,9 @@ //cluster-emitter is a different EventEmitter which allows all messages send between master & slaves, with an additional parameters as 'target' | ||
}); | ||
emitter.on('ask-parent-pid', function(childPid){ | ||
//just to tell the child the parent's pid, sends null if it's the parent itself asking | ||
if(childPid){ | ||
emitter.to([childPid]).emit('reply-parent-pid', process.pid === childPid ? null : process.pid); | ||
} | ||
}); | ||
} | ||
@@ -243,0 +250,0 @@ else{ |
{ | ||
"name": "cluster-emitter", | ||
"version": "0.5.0-SNAPSHOT.1387314416214", | ||
"version": "0.5.0-SNAPSHOT.1388501015412", | ||
"description": "cluster-emitter ===============", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -40,2 +40,18 @@ 'use strict'; | ||
it('should return parent pid as null', function(done){ | ||
this.timeout(500); | ||
var emitter = require('../index'); | ||
emitter.should.be.ok; | ||
emitter.once('reply-parent-pid', function(parentPid){ | ||
//parentPid should be null | ||
done(parentPid); | ||
}); | ||
emitter.emit('ask-parent-pid', process.pid); | ||
}) | ||
}); | ||
@@ -42,0 +58,0 @@ |
@@ -111,4 +111,4 @@ 'use strict'; | ||
logger.info('[worker:%d] received:%s and will emit:%s', process.pid, eventToMe, echo); | ||
emitter.emit(echo, process.pid); | ||
logger.info('[worker:%d] emitted:%s with payload:%s', process.pid, echo, process.pid); | ||
emitter.emit(echo, process.pid, process.parentPid); | ||
logger.info('[worker:%d] emitted:%s with payload:%s, %s', process.pid, echo, process.pid, process.parentPid); | ||
}); | ||
@@ -115,0 +115,0 @@ |
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
16014
339