ase

gossip-like protocol to maintain a distributed network of peers

npm install ase
25 downloads in the last month

ase

NPM version Build Status Dependency Status Coverage Status Code Climate Technical debt analysis

ase implements a gossip-like protocol with failure detection

install

$ npm install ase

example

var ase = require('./')

var peer1 = ase(function (e) {
  if(e) throw e
  console.log('%s is listening', peer1.name)

  var peer2 = ase([peer1.name])

  setTimeout(function () {
    peer2.stop()
  }, 4000)

  setTimeout(function () {
    peer2.start()
  }, 8000)
})

peer1.on('new', function (peer) {
  console.log('new peer found in the network: %s', peer.name())
})

peer1.on('alive', function (peer) {
  console.log('%s was dead but it\'s now alive', peer.name())
  process.exit()
})

peer1.on('failed', function (peer) {
  console.log('%s just failed', peer.name())
})

cli example

$ node bin/example.js
192.168.1.14:53873 started
$ node bin/example.js --seeds=192.168.1.14:53873
192.168.1.14:53888 started
Found: 192.168.1.14:53873
$ node bin/example.js --seeds=192.168.1.14:53873
192.168.1.14:53897 started
Found: 192.168.1.14:53873
Found: 192.168.1.14:53888

license

npm loves you