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 interface to Hadoop Zookeeper based on the native C-client API for Zookeeper
npm install zookeeper
var ZK = require ("zookeeper").ZooKeeper;
var zk = new ZK();
zk.init ({connect:"localhost:2181", timeout:200000, debug_level:ZK.ZOO_LOG_LEVEL_WARNING, host_order_deterministic:false});
zk.on (ZK.on_connected, function (zkk) {
console.log ("zk session established, id=%s", zkk.client_id);
zkk.a_create ("/node.js1", "some value", ZK.ZOO_SEQUENCE | ZK.ZOO_EPHEMERAL, function (rc, error, path) {
if (rc != 0)
console.log ("zk node create result: %d, error: '%s', path=%s", rc, error, path);
else {
console.log ("created zk node %s", path);
process.nextTick(function () {
zkk.close ();
});
}
});
});
This prints the following:
zk session established, id=12c03eda65800b8
created zk node /node.js10000001001
See illustration of all other ZK methods in tests/zk_test_chain.js
This is an attempt to expose Hadoop Zookeeper to node.js client applications. The bindings are implemented in C++ for V8 and depend on zk C api library.
The following API calls closely follow ZK C API call. So, consult with ZK Reference for details.
The following apply for these apis:
Regular async APIs:
_
( path, version, void_cb )
_
is added to avoid conflict with reserved word _delete_
since zk_promise.js strips off prefix a_
from all operations)APIs based on watchers (watcher is a forward-looking subscription to changes on the node in context):
Session state machine is well described in Zookeeper docs, i.e.
zk_r.on_connected().
then (
function (zkk){
console.log ("reader on_connected: zk=%j", zkk);
return zkk.create ("/node.js2", "some value", ZK.ZOO_SEQUENCE | ZK.ZOO_EPHEMERAL);
}
).then (
function (path) {
zk_r.context.path = path;
console.log ("node created path=%s", path);
return zk_r.w_get (path,
function (type, state, path_w) { // this is a watcher
console.log ("watcher for path %s triggered", path_w);
deferred_watcher_triggered.resolve (path_w);
}
);
}
).then (
function (stat_and_value) { // this is the response from w_get above
console.log ("get node: stat=%j, value=%s", stat_and_value[0], stat_and_value[1]);
deferred_watcher_ready.resolve (zk_r.context.path);
return deferred_watcher_triggered;
}
).then (
function () {
console.log ("zk_reader is finished");
process.nextTick( function () {
zk_r.close ();
});
}
);
node-waf configure build [--zookeeper zookeeper-version|prefix-path|'']
node demo1.js
cd tests && node zk_test_XYZ.js
node: if you wish to build with a specific version of zookeeper C lib, use --zookeeper VERSION (will download/build it) or --zookeeper PATH (if you have downloaded it and possibly made changes etc.)
note: if you wish to link against an existing zookeeper lib: use --zoookeeper '', and put your lib/headers it in /usr/local/ (or edit the wscript appropriately)
note: if you are building on osx and you get a compile error regarding "mmacosx-version-min", you may need to edit the wscript and remove it (anyone with the answer please explain/fix if possible).
note: if you are building on a platform for which the options are not working, please add a specific elif for that platform and create a pull request.
Data coming out of ZooKeepr (in callbacks) will now default to being Buffer objects. The main ZK handle now has a boolean attribute called 'data_as_buffer', which defaults to true. If you are storing strings only, as was only allowed in the initial implementation, or you wish to have data in callbacks arrive as strings, you add 'data_as_buffer:false' to the init options, or add 'zk.data_as_buffer = false;' before using the handle. The behavior defaults to Buffer objects because this aligns more closely with ZooKeeper itself which uses byte arrays. They are interchangable on input, if the input is a Buffer it'll be used directly, otherwise the toString() of the input is used (this will work with utf8 data as well) regardless of mode.
See LICENSE-MIT.txt file in the top level folder.
Yuri Finkelstein (yurif2003 at yahoo dot com)
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.