2.0.3 • Published 7 years ago

elector v2.0.3

Weekly downloads
65
License
MIT
Repository
github
Last release
7 years ago

Elector - simple zookeeper based leader election

Build Status Greenkeeper badge npm version

Features

  • emits leader event when instance has been elected a leader
  • emits follower event when instance is a follower
  • check using elector.isLeader

Install

npm install --save elector

Usage

const Elector = require('elector')

const elector = new Elector({host: 'localhost:2818'})

// alternatively pass in zookeeper client
// const elector = new Elector(new zookeeper.createClient('localhost:2818'))

// connects to zookeeper and starts the election process
elector.connect()

elector.on('leader', function () {
	console.log('I am the supreme leader worship me!')
})

elector.on('follower', function () {
	console.log('I am but a lowly follower :(')
})

// leave the election and closes zookeeper connection
// do this to leave the election quickly
// elector.disconnect()

License

MIT

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago