messenger-pool
v0.0.6
Published
A connection pool for communication between node.js instances/servers
Downloads
21
Readme
Messenger-pool - Fast Node.js json over tcp connection pool
Installation
npm install messenger-pool
this package is based on Messenger.js the syntax is the same, only this repo supports both a single connection, and a connection pool
this packege uses node-pool to do the connection pooling
Example:
var messenger = require('messenger-pool');
var poolOptions = {
max : 10,
min : 2,
idleTimeoutMillis : 30000
};
var client = messenger.createSpeakerPool(8000, poolOptions);
var server = messenger.createListener(8000);
server.on('give it to me', function(message, data){
message.reply({'you':'got it'});
});
setInterval(function(){
client.request('give it to me', {hello:'world'}, function(data){
console.log(data);
});
}, 1000);
Output:
> {'you':'got it'}
> {'you':'got it'}
> ...etc...
more examples, and syntax for single connection without pooling could be found in Messenger.js docs
all optional and default values for poolOptions could be found in node-pool docs