Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
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');
function onCreate(client, rc, error, path) {
if (rc !== 0) {
console.log(`zk node create result: ${rc}, error: '${error}', path=${path}`);
} else {
console.log(`created zk node ${path}`);
process.nextTick(() => {
client.close();
});
}
}
function onConnect(client, err) {
if (err) {
throw err;
}
console.log(`zk session established, id=${client.client_id}`);
client.a_create('/node.js1', 'some value', ZooKeeper.ZOO_SEQUENCE | ZooKeeper.ZOO_EPHEMERAL, onCreate.bind(null, client));
}
const zk = new ZooKeeper({
connect: '127.0.0.1:2181',
timeout: 200000,
debug_level: ZooKeeper.ZOO_LOG_LEVEL_WARN,
host_order_deterministic: false,
});
try {
zk.connect(onConnect.bind(null, zk));
} catch (e) {
console.error(e);
}
_
( path, version, void_cb )
_
is added to avoid conflict with reserved word _delete_
since zk_promise.js strips off prefix a_
from all operations)The watcher methods are forward-looking subscriptions that can recieve multiple callbacks whenever a matching event occurs.
Session state machine is well described in Zookeeper docs, i.e.
It's supported now, 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:
Example:
var ZooKeeper = require("zookeeper");
zk = new ZooKeeper({
connect: "localhost:2181",
timeout: 2000,
});
var key = "/acl-test";
zk.connect(function (err, client) {
if (err) throw err;
console.log("zoolocker: Connected to Zookeeper, id=%s", zk.client_id);
client.add_auth("digest", "username:password", function (rc, error) {
console.log("ADD_AUTH", rc, error);
client.a_create(key, "", {
version: -1
}, function (rc, error, path) {
console.log("CREATE", rc, error);
client.a_set_acl(key, -1, [ZooKeeper.ZOO_CREATOR_ALL_ACL, ZooKeeper.ZOO_OPEN_ACL_UNSAFE, {
perms: ZooKeeper.ZOO_PERM_WRITE,
scheme: "world",
auth: "anyone",
}], function (rc, error) {
console.log("SET_ACL", rc, error);
client.a_get_acl(key, function (rc, error, acl, stat) {
console.log("GET_ACL", rc, error, acl);
});
});
});
});
});
For more details please refer to ZooKeeper docs.
Install CMake
to build a ZooKeeper client on Windows. Python 2.7.x
is currently required by the tool node-gyp
to build the ZooKeeper client as a native Node.js Addon.
Also, run npm install
in a Powershell window as an Administrator.
Windows support has been enabled mainly for supporting development, not for production.
Fixes:
TODO:
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 will be used directly, otherwise the toString() of the input is used (this will work with utf8 data as well) regardless of mode.
With the new Buffer changes in the 0.3+ and 0.4+ branches, these will be internal 'SlowBuffer' objects, and you should use Buffer.isBuffer if you are checking the type, as 'instanceof Buffer' will return false.
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-gyp configure build
DDOPSON-2011-11-30 - are these issues still relevant? unknown.
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.0.1 (2019-03-10)
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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
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.