Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eggjs/egg-zookeeper
egg plugin for zookeeper
https://github.com/eggjs/egg-zookeeper
egg egg-plugin plugin zookeeper
Last synced: 4 days ago
JSON representation
egg plugin for zookeeper
- Host: GitHub
- URL: https://github.com/eggjs/egg-zookeeper
- Owner: eggjs
- License: mit
- Created: 2017-02-13T14:33:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-27T04:16:06.000Z (over 6 years ago)
- Last Synced: 2024-04-14T02:21:18.139Z (7 months ago)
- Topics: egg, egg-plugin, plugin, zookeeper
- Language: JavaScript
- Size: 4.17 MB
- Stars: 20
- Watchers: 10
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
- awesome-egg - egg-zookeeper - zookeeper plugin for egg ![](https://img.shields.io/github/stars/eggjs/egg-zookeeper.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/egg-zookeeper.svg?style=flat-square) (仓库 / 插件)
- awesome-egg - egg-zookeeper - zookeeper plugin for egg (Plugins)
README
# egg-zookeeper
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![NPM download][download-image]][download-url][npm-image]: https://img.shields.io/npm/v/egg-zookeeper.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-zookeeper
[travis-image]: https://img.shields.io/travis/node-modules/egg-zookeeper.svg?style=flat-square
[travis-url]: https://travis-ci.org/node-modules/egg-zookeeper
[codecov-image]: https://codecov.io/gh/node-modules/egg-zookeeper/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/node-modules/egg-zookeeper
[david-image]: https://img.shields.io/david/node-modules/egg-zookeeper.svg?style=flat-square
[david-url]: https://david-dm.org/node-modules/egg-zookeeper
[snyk-image]: https://snyk.io/test/npm/egg-zookeeper/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-zookeeper
[download-image]: https://img.shields.io/npm/dm/egg-zookeeper.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-zookeeperegg plugin for zookeeper
## Install
```bash
npm i egg-zookeeper --save
```## Usage
1. Install & enable the plugin in egg
```js
// config/plugin.js
exports.zookeeper = {
enable: true,
package: 'egg-zookeeper',
};
```2. Create zk client with `app.zk.createClient(connectionString)` api
```js
const client = app.zk.createClient('localhost:2181');
yield client.ready();const path = '/test-path';
function listChildren(client, path) {
client.getChildren(
path,
event => {
console.log('Got watcher event: %s', event);
listChildren(client, path);
},
(err, children, stat) => {
if (err) {
console.log('Failed to list children of %s due to: %s.', path, err);
return;
}
console.log('Children of %s are: %j.', path, children);
}
);
}// create a new path
client.create(path, err => {
if (err) {
console.log('Failed to create node: %s due to: %s.', path, err);
} else {
console.log('Node: %s is successfully created.', path);
}// list and watch the children of given node
listChildren();
});
```## APIs
Please refer to [zookeeper-cluster-client](https://www.npmjs.com/package/zookeeper-cluster-client) in detail.
## License
[MIT](LICENSE.txt)