Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
node-zookeeper - A Node.js client for Apache Zookeeper.
This module is implemented on top of the ZooKeeper C API; consult the ZK Reference for further details on behavior.
Latest changes are described in the changelog
(note the name zookeeper
in lowercase)
npm install zookeeper
const ZooKeeper = require('zookeeper');
The ZooKeeper client support both callbacks and async/await
.
The source code is documented with JSDoc
code comments and TypeScript
type declarations.
Also, have a look at the API documentation here:
Create an instance of the ZooKeeper client using async/await
:
function createClient(timeoutMs = 5000) {
const config = {
connect: host,
timeout: timeoutMs,
debug_level: ZooKeeper.ZOO_LOG_LEVEL_WARN,
host_order_deterministic: false,
};
return new ZooKeeper(config);
}
const client = createClient();
The client is ready when connected to a ZooKeeper server:
client.on('connect', () => {
// start using the client
});
client.init(config);
Using the API of the async/await
enabled client.
const path = '/myPath';
try {
const createdPath = await client.create(path, data, ZooKeeper.ZOO_EPHEMERAL);
console.log(`(created: ${createdPath})`);
} catch (error) {
console.log(`${path} already exists`);
}
Check out the code in the examples folder: master,workers, tasks and listeners scenarios.
init(options)
connect(options, connect_cb)
close()
path = await create(path, data, flags)
mkdirp(path, callback(Error))
stat = await exists(path, watch)
data = await get(path, watch)
children = await get_children(path, watch)
[children, stat] = await get_children2( path, watch)
stat = await set(path, data, version)
val = await sync(path)
delete_ (path, version)
_
)set_acl(path, version, acl)
acl = await get_acl(path)
add_auth(scheme, auth)
The watcher methods are forward-looking subscriptions that can recieve multiple callbacks whenever a matching event occurs.
stat = await w_exists(path, watch_cb)
data = await w_get(path, watch_cb)
children = await w_get_children(path, watch_cb)
[children, stat] = await w_get_children2 (path, watch_cb)
init(options)
connect(options, connect_cb)
close()
a_create(path, data, flags, path_cb)
mkdirp(path, callback(Error))
a_exists(path, watch, stat_cb)
a_get(path, watch, data_cb)
a_get_children(path, watch, child_cb)
a_get_children2(path, watch, child2_cb)
a_set(path, data, version, stat_cb)
a_sync(path, value_cb)
a_delete_ (path, version, void_cb)
_
)a_set_acl(path, version, acl, void_cb)
a_get_acl(path, acl_cb)
add_auth(scheme, auth, void_cb)
The watcher methods are forward-looking subscriptions that can recieve multiple callbacks whenever a matching event occurs.
aw_exists(path, watch_cb, stat_cb)
aw_get(path, watch_cb, data_cb)
aw_get_children(path, watch_cb, child_cb)
aw_get_children2(path, watch_cb, child2_cb)
Session state machine is well described in the Zookeeper docs
The library comes with 3 default ACL levels defined (comes from ZK):
If you don't want to use predefined ACLs you can define your own (the ACL object is described above), for limiting permisions you can use:
For more details please refer to ZooKeeper docs.
Install CMake
to build a ZooKeeper client on Windows. Install Python.
Also, run npm install
in a Powershell window. For further instructions visit node-gyp documentation.
Windows support has been enabled mainly for supporting development, not for production.
To run full output during the module build one has to use ZK_INSTALL_VERBOSE
flag.
ZK_INSTALL_VERBOSE=1 npm install
$env:ZK_INSTALL_VERBOSE=1
npm install
This PowerShell command will remove the environment variable:
Remove-Item Env:\ZK_INSTALL_VERBOSE
Check out the issues tab and grab one! Read the contributing document.
See LICENSE-MIT.txt file in the top level folder.
Yuri Finkelstein (yurif2003 at yahoo dot com)
with awesome contributions from:
v 4.7.0-beta.0 (2020-11-29)
FAQs
apache zookeeper client (zookeeper async API v3.5.x - v3.8.x)
The npm package zookeeper receives a total of 4,578 weekly downloads. As such, zookeeper popularity was classified as popular.
We found that zookeeper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.