Socket
Socket
Sign inDemoInstall

elector

Package Overview
Dependencies
6
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    elector

simple zookeeper based leader election


Version published
Weekly downloads
2
Maintainers
1
Install size
2.30 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 14 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc