zoo-leader
v1.0.5
Published
A client of zookeeper to determine whether it is a Leader
Downloads
8
Maintainers
Readme
zoo-leader
A client of zookeeper to determine whether it is a Leader
const ZooLeader = require("zoo-leader");
const options = {
connect: "127.0.0.1:2181",
timeout: 5000,
debug_level: 1,
host_order_deterministic: true,
logger: console,
rootPath: "/UniversalUniquKey"
};
// init
let zl = new ZooLeader(options);
yield zl.init();
// event fire
zl.afterLeaderChange = function(sender, isLeader){};
// multiple leader
let anotherLeader = zl.nodePosition === 1;
zl.afterNodePositionChange = function(sender, oldPosition, newPosition){}
// ...
// before exit
zl.close();