zookeeper-util
A simple utility Boilerplate code for Zookeeper Clients (Promise based)
Typescript:
;try await ZookeeperUtil; // Zookeeper Connected const result = await ZookeeperUtil; catche
Node.js:
const zookeeperUtil = ;const PROPERTY_TYPES = NUMBER: 0 STRING: 1 OBJECT: 2 BOOLEAN: 3; try await ZookeeperUtil; // Zookeeper Connected const result = await ZookeeperUtil; catche
Installation
$ npm install zookeeper-util
API Reference
Objects
zkInfo
Passed in the init method
connectionParam
: Comma seperated list of Ip:port (Cluster/Standalone)basePath
: Base Path for the Zookeeper Client. All the property get would be referenced with this base path.options
: Zookeeper Options, passed as it is. Please refer tonode-zookeeper-client
for all available options
PropertyType
enum { STRING, NUMBER, BOOLEAN, OBJECT }
Methods
ZookeeperUtil.init(zkInfo);
Used to init the client; opens connections to ZK
Usage:
ZookeeperUtil;
Returns a void Promise
ZkUtil.getProperty(propertyKey, propertyType, watcher);
Get the Zookeeper Property. Watcher is optional
Usage:
// Absolute Path: basePath + propertyKeyconst result = await ZookeeperUtil; ZookeeperUtil;
Returns a Promise
Note: /
in the getProperty should be validated with the basePath suffixing with /
ZkUtil.setProperty(propertyKey, data);
Sets the Zookeeper Property. Data Types supported are Property Types mentioned above
Usage:
ZookeeperUtil; ZookeeperUtil;
Returns a void Promise
Note: /
in the setProperty should be validated with the basePath suffixing with /
/
ZkUtil.registerWatcher(propertyKey, propertyType, watcher);
Sets the Zookeeper Watcher on the Property. Data Types supported are Property Types mentioned above
Usage:
const watcher = {};ZookeeperUtil;
Returns void