ase

0.1.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i ase

Weekly Downloads

4

Version

0.1.4

License

none

Last publish

Collaborators

  • ramitos