marco
v0.0.4
Published
A skinny library for establishing leadership consensus among multiple nodes in a distributed network. Uses Redis pubsub for signaling. Great for distributed job runners/schedulers.
Downloads
15
Maintainers
Readme
Marco
A skinny library for establishing leadership consensus among multiple nodes in a distributed network. Uses Redis pubsub for signaling.
Provides a good foundation for creating distributed job scheduling/running systems or other applications where master/slave roles need to be agreed upon by many nodes.
Installation
$ npm install marco
Example
var Marco = require('marco');
// Heroku Redistogo URL
var rtg = require('url').parse('redis://redistogo:[email protected]:14687/');
var jobDynoConfig = {
redis: {
port: rtg.port,
hostname: rtg.hostname,
auth: rtg.auth.split(':')[1]
}
};
var marco = new Marco(jobDynoConfig);
marco.on('roleChange',function(data){
console.log('There was a role change:',data);
// $ There was a role change: {from:undefined,to:'scheduler',connected:[2839]}
});
marco.go();