harcon-amqp
Advanced tools
Comparing version 0.3.1 to 0.4.0
var rabbit = require('rabbit.js'); | ||
var Harcon = require('harcon'); | ||
var async = require('async'); | ||
var Barrel = Harcon.Barrel; | ||
@@ -10,2 +11,41 @@ var Communication = Harcon.Communication; | ||
amqpbarrel.createPull = function( division, callback ){ | ||
var self = this; | ||
var pull = self.ctx.socket('PULL'); | ||
self.pulls[division] = pull; | ||
pull.setEncoding('utf8'); | ||
pull.on('readable', function( message ){ | ||
var msg; | ||
while( (msg = self.pulls[division].read()) ) { | ||
var comm = JSON.parse( msg ); | ||
self.innerProcessAmqp( comm ); | ||
} | ||
} ); | ||
pull.connect( division, function( ) { | ||
self.logger.harconlog( null, 'AMQP pull queue is made.', division, 'info' ); | ||
if( callback ) | ||
callback( ); | ||
} ); | ||
pull.on('error', self.logger.error ); | ||
}; | ||
amqpbarrel.createPush = function( division, callback ){ | ||
var self = this; | ||
var push = self.ctx.socket('PUSH'); | ||
push.setDefaultEncoding('utf8'); | ||
push.connect( division, function() { | ||
self.logger.harconlog( null, 'AMQP push queue is made.', division, 'info' ); | ||
self.pushs[division] = push; | ||
if( callback ) | ||
callback(); | ||
} ); | ||
push.on('error', self.logger.error ); | ||
}; | ||
amqpbarrel.extendedInit = function( config, callback ){ | ||
@@ -17,3 +57,2 @@ var self = this; | ||
var connectURL = config.connectURL || 'amqp://localhost'; | ||
var handlerFn = self.processAmqp.bind(self); | ||
self.ctx = rabbit.createContext( connectURL ); | ||
@@ -23,12 +62,6 @@ self.ctx.on('ready', function() { | ||
self.pushs = {}; | ||
self.pull = self.ctx.socket('PULL'); | ||
self.pull.setEncoding('utf8'); | ||
self.pull.on('readable', handlerFn ); | ||
self.pull.connect( self.division, function( ) { | ||
self.logger.harconlog( null, 'AMQP pull queue is made.', self.division, 'info' ); | ||
self.pulls = {}; | ||
if( callback ) | ||
callback( ); | ||
} ); | ||
self.pull.on('error', self.logger.error ); | ||
if( callback ) | ||
callback(); | ||
} ); | ||
@@ -43,13 +76,10 @@ self.ctx.on('error', self.logger.error ); | ||
var self = this; | ||
var push = self.ctx.socket('PUSH'); | ||
push.setDefaultEncoding('utf8'); | ||
push.connect( division, function() { | ||
self.logger.harconlog( null, 'AMQP push queue is made.', division, 'info' ); | ||
self.pushs[division] = push; | ||
if( callback ) | ||
callback(); | ||
async.series( [ | ||
function(cb){ self.createPull( division, cb ); }, | ||
function(cb){ self.createPush( division, cb ); } | ||
], callback || function(err){ | ||
if(err) | ||
console.error( err ); | ||
} ); | ||
push.on('error', self.logger.error ); | ||
}; | ||
@@ -80,11 +110,2 @@ | ||
amqpbarrel.processAmqp = function( message ){ | ||
var self = this; | ||
var msg; | ||
while( (msg = self.pull.read()) ) { | ||
var comm = JSON.parse( msg ); | ||
self.innerProcessAmqp( comm ); | ||
} | ||
}; | ||
amqpbarrel.parentAppease = amqpbarrel.appease; | ||
@@ -91,0 +112,0 @@ amqpbarrel.appease = function( comm, err, responseComms ){ |
{ | ||
"name": "harcon-amqp", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "AMQP plugin for the harcon messaging/service bus of node-based enterprise entities.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -13,8 +13,9 @@ var CleanTester = require('./CleanTest'); | ||
'init' | ||
, 'activatePublisher' | ||
, 'addVivian' | ||
, 'checkHealth' | ||
//, 'checkVivian' | ||
//, 'checkMarie' | ||
//, 'checkGreetings' | ||
//, 'checkMorningGreetings' | ||
, 'checkVivian' | ||
, 'checkMarie' | ||
, 'checkGreetings' | ||
, 'checkMorningGreetings' | ||
, 'checkDomina' | ||
@@ -25,7 +26,6 @@ , 'close' | ||
var tasks = []; | ||
console.log('------'); | ||
fnNames.forEach(function( fnName ){ | ||
tasks.push(function(cb){ | ||
CleanTester[fnName]( function(err){ | ||
console.log('------'); | ||
console.log('------ ' + fnName + ' done. ------'); | ||
error(err); | ||
@@ -36,4 +36,6 @@ cb(); | ||
}); | ||
async.series(tasks, function(err, res){ | ||
console.log(err, res); | ||
if(err) | ||
console.error(err); | ||
}); |
@@ -19,2 +19,8 @@ var chai = require('chai'), | ||
}, | ||
activatePublisher: function( callback ){ | ||
var self = this; | ||
self.harcon.addicts( Publisher ); | ||
Publisher.watch( './test/components', -1 ); | ||
callback(); | ||
}, | ||
addVivian: function(callback){ | ||
@@ -29,5 +35,2 @@ var self = this; | ||
}; | ||
self.harcon.addicts( Publisher ); | ||
Publisher.watch( './test/components', -1 ); | ||
self.harcon.addicts( Vivian, {}, function(){ | ||
@@ -56,3 +59,2 @@ callback(); | ||
this.harcon.simpleIgnite( 'Marie.simple', 'whatsup?', 'how do you do?', function(err, res){ | ||
console.log('>>>>>>>>>>>>>>', err, res); | ||
should.not.exist(err); should.exist(res); | ||
@@ -65,3 +67,2 @@ expect( res ).to.include( 'Bonjour!' ); | ||
this.harcon.simpleIgnite( 'greet.simple', 'whatsup?', 'how do you do?', function(err, res){ | ||
console.log( '>>>>>>>>>>>>>>', err, res ); | ||
should.not.exist(err); should.exist(res); | ||
@@ -76,3 +77,2 @@ | ||
this.harcon.simpleIgnite( 'dawn.wakeup', function(err, res){ | ||
console.log( '>>>>>>>>>>>>>>', err, res ); | ||
expect(err).to.be.a('null'); | ||
@@ -85,3 +85,2 @@ expect( res[0] ).to.include( 'Bonjour!' ); | ||
this.harcon.simpleIgnite( 'Domina.force', function(err, res){ | ||
console.log( '>>>>>>>>>>>>>>', err, res ); | ||
done( ); | ||
@@ -88,0 +87,0 @@ } ); |
@@ -6,3 +6,3 @@ module.exports = { | ||
init: function (options) { | ||
//console.log('Init...', options); | ||
console.log('Init...', options); | ||
}, | ||
@@ -9,0 +9,0 @@ // Simple service function listening to the greet.usual message where greet comes from context and usual is identified by the name of the fuction. |
@@ -10,14 +10,9 @@ var async = require('async'); | ||
function(cb){ | ||
console.log('???????????'); | ||
ignite( 0, '', 'greet.gentle', 'It is morning!', 'Time to wake up!', cb ); | ||
ignite( 0, '', 'greet.simple', 'It is morning!', 'Time to wake up!', cb ); | ||
}, | ||
function(cb){ | ||
console.log('???????????'); | ||
ignite( 1, 'click', 'Claire.simple', 'It is morning!', 'Time to wake up!', cb ); | ||
ignite( 1, 'Inflicter.click', 'Claire.simple', 'It is morning!', 'Time to wake up!', cb ); | ||
} | ||
], function(err, res){ | ||
console.log('::::::', err, res); | ||
callback(err, res); | ||
}); | ||
], callback ); | ||
} | ||
}; |
@@ -5,3 +5,3 @@ module.exports = { | ||
init: function (options) { | ||
//console.log('Init...', options); | ||
console.log('Init...', options); | ||
}, | ||
@@ -11,4 +11,5 @@ // Simple service function listening to the greet.simple message where greet comes from context and simple is identified by the name of the fuction. | ||
this.greetings = [greetings1, greetings2]; | ||
this.shifted( { data: 'content' } ); | ||
callback(null, 'Bonjour!'); | ||
} | ||
}; |
@@ -7,3 +7,5 @@ var CleanTester = require('./CleanTest'); | ||
CleanTester.init( function(){ | ||
CleanTester.addVivian( done ); | ||
CleanTester.activatePublisher( function(){ | ||
CleanTester.addVivian( done ); | ||
} ); | ||
} ); | ||
@@ -10,0 +12,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
36147
552