{"library":"node-zookeeper-client","title":"Node.js Pure JavaScript ZooKeeper Client","description":"node-zookeeper-client is a pure JavaScript client for Apache ZooKeeper, designed to mirror the ZooKeeper Java client API while adhering to Node.js conventions. It provides core functionalities like connecting, creating/removing nodes, retrieving/setting data, and managing ACLs. The current stable version is 1.1.3, last published over four years ago, indicating it is no longer actively maintained. This client has been tested against ZooKeeper version 3.4.*. Unlike some alternatives that wrap the C client, this package is entirely JavaScript-based. Its release cadence is effectively non-existent due to its abandoned status, and it primarily supports callback-based asynchronous operations.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install node-zookeeper-client"],"cli":null},"imports":["import { createClient } from 'node-zookeeper-client';","const zookeeper = require('node-zookeeper-client');","const { Event } = require('node-zookeeper-client');\n// or\nconst zookeeper = require('node-zookeeper-client');\nconst Event = zookeeper.Event;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const zookeeper = require('node-zookeeper-client');\n\nconst client = zookeeper.createClient('localhost:2181');\nconst path = '/my-test-node'; // Using a fixed path for a runnable example\nconst data = Buffer.from('Hello ZooKeeper');\n\nclient.once('connected', function () {\n    console.log('Connected to the ZooKeeper server.');\n\n    client.create(path, data, zookeeper.ACL.OPEN_ACL_UNSAFE, zookeeper.CreateMode.EPHEMERAL, function (error) {\n        if (error) {\n            if (error.getCode() === zookeeper.Exception.NODE_EXISTS) {\n                console.log('Node %s already exists, skipping creation.', path);\n            } else {\n                console.error('Failed to create node: %s due to: %s.', path, error);\n                client.close();\n                return;\n            }\n        } else {\n            console.log('Node: %s is successfully created with data: %s.', path, data.toString());\n        }\n\n        // Example of getting data\n        client.getData(path, function (event) {\n            console.log('Watcher triggered for %s: %s', path, event);\n        }, function (error, data, stat) {\n            if (error) {\n                console.error('Failed to get data from %s due to: %s.', path, error);\n            } else {\n                console.log('Data of %s is: %s (version: %d).', path, data.toString(), stat.version);\n            }\n            client.close();\n        });\n    });\n});\n\nclient.on('error', function (error) {\n    console.error('ZooKeeper client encountered an error: %s', error.stack);\n});\n\nclient.connect();","lang":"javascript","description":"This example connects to a local ZooKeeper instance, creates an ephemeral node with data, and then attempts to retrieve its data with a watcher, handling potential 'node exists' errors.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}