zklua
zklua copied to clipboard
how to set the ACL parameter
anybody know how to set the format of ACL when to call acreate function
zookeeper.h /** This is a completely open ACL_/ extern ZOOAPI struct ACL_vector ZOO_OPEN_ACL_UNSAFE; /_* This ACL gives the world the ability to read. / extern ZOOAPI struct ACL_vector ZOO_READ_ACL_UNSAFE; /* This ACL gives the creators authentication id's all permissions. */ extern ZOOAPI struct ACL_vector ZOO_CREATOR_ALL_ACL;
so you can register these struct to lua.
from zklua.c(line 320) function _zklua_parse_acls
, we can see ACL is a table in Lua, and you can pass N ACL, each ACL is consist of three items, the code is like below
local acl = {
{
perms = 31, -- const int ZOO_PERM_ALL = 0x1f;
scheme = "world",
id = "anyone" -- world:anyone means anybody
}
}
local ret, err = zklua.create(zh, "/zklua/test", "test", acl, 0)
if ret ~= 0 then
print("error:"..err)
end
the normal return code of the create
is 0 and error code is descripted in https://github.com/apache/zookeeper/blob/master/src/c/include/zookeeper.h#120.
Hope to help.