Comparing version 0.9.3 to 0.9.4
@@ -9,4 +9,5 @@ var async = require('async'); | ||
*/ | ||
function Barrel( logger ){ | ||
function Barrel( systemName, logger ){ | ||
this.firestarters = [ ]; | ||
this.systemName = systemName; | ||
this.logger = logger; | ||
@@ -71,3 +72,3 @@ } | ||
if( (comm.source === fs.name) || (fs.listeningToResponses && fs.matches( comm.event ) ) ){ | ||
fs.appease( comm, responseComms ); | ||
fs.appease( err, comm, responseComms ); | ||
} | ||
@@ -84,8 +85,13 @@ } ); | ||
barrel.intoxicate = function( comm ){ | ||
var self = this; | ||
var matching = this.firestarters.filter( function( fs ){ return fs.matches( comm.event ); } ); | ||
if( matching.length === 0 ) | ||
if( matching.length === 0 ){ | ||
// name, error, response | ||
if( comm.callback ) | ||
self.appease( comm, new Error('Nobody is listening'), null ); | ||
return this.logger.harconlog( new Error('Nobody is listening'), 'Nobody is listening', {comm: comm }, 'warn'); | ||
} | ||
var self = this; | ||
var callChain = matching.map( function( fs ){ | ||
@@ -92,0 +98,0 @@ return function( cb ){ |
@@ -36,3 +36,5 @@ var Communication = require('./Communication'); | ||
*/ | ||
firestarter.conformResponse = function( responseComms ){ | ||
firestarter.conformResponse = function( error, responseComms ){ | ||
if( error ) return { err: error, res: null }; | ||
var err, res; | ||
@@ -60,5 +62,5 @@ | ||
*/ | ||
firestarter.appease = function( comm, responseComms ){ | ||
firestarter.appease = function( error, comm, responseComms ){ | ||
if( this.comms[ comm.id ] ){ | ||
var response = this.conformResponse( responseComms ); | ||
var response = this.conformResponse( error, responseComms ); | ||
if( this.comms[ comm.id ].callback ) | ||
@@ -65,0 +67,0 @@ this.comms[ comm.id ].callback( response.err, response.res ); |
@@ -47,3 +47,3 @@ var Communication = require('../lib/Communication'); | ||
this.barrel = new Barrel( this.logger ); | ||
this.barrel = new Barrel( this.name, this.logger ); | ||
@@ -50,0 +50,0 @@ this.inflicterContext = (this.options.context || {}); |
{ | ||
"name": "harcon", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Messaging/Service Bus for the harmonic convergence of node-based enterprise entities.", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
}, | ||
"_id": "harcon@0.9.3" | ||
"_id": "harcon@0.9.4" | ||
} |
@@ -62,5 +62,19 @@ var chai = require("chai"); | ||
expect(err).to.be.a('null'); | ||
expect(res[0]).to.eql( [ 'Hi there!', 'My pleasure!' ] ); | ||
done( ); | ||
} ); | ||
}); | ||
it('No answer', function(done){ | ||
// Sending a morning message and waiting for the proper answer | ||
inflicter.ignite( 'cave.echo', function(err, res){ | ||
console.log( err, res ); | ||
expect(err).to.be.an.instanceof( Error ); | ||
expect(res).to.be.a('null'); | ||
done( ); | ||
} ); | ||
}); | ||
}); | ||
@@ -67,0 +81,0 @@ |
Sorry, the diff of this file is not supported yet
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
683137
9422