Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example code for ACL #194

Open
DavidVujic opened this issue Jul 27, 2019 · 1 comment
Open

Add example code for ACL #194

DavidVujic opened this issue Jul 27, 2019 · 1 comment

Comments

@DavidVujic
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
There should be a working runnable code example for using the ACL feature of the library. Example code exist in the README, but that one is not longer valid (the API was probably different at the time of writing). The current example will be removed from the README shortly.

Describe the solution you'd like
A JavaScript file with ACL example code, in the examples folder. The code should use the Promise based ZooKeeper client. This file should be able to run using node examples/acl.js.

Additional context
This is the example code (that is not currently working) from the README:

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);
                });
            });
        });
    });
});
@nitin-pandita
Copy link

I would like to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants