php Zookeeper使用踩坑

2022-08-03 13:39:14 字數 2741 閱讀 9439

用的是0.6.4版本

建立節點官方給的示例如下:

<?php

$zookeeper = new zookeeper('locahost:2181');

$aclarray = array(

array(

'perms' => zookeeper::perm_all,

'scheme' => 'world',

'id' => 'anyone',

));$path = '/path/to/newnode';

$realpath = $zookeeper->create($path, null, $aclarray);

if ($realpath)

echo $realpath;

else

echo 'err';

?>

一直報無效的acl,檢視源**:

static

void php_parse_acl_list(zval *z_acl, struct acl_vector *aclv)

aclv->data = (struct acl *)calloc(size, sizeof(struct

acl));

#ifdef zend_engine_3

zend_hash_foreach_key_val(z_arrval_p(z_acl), index, key, entry)

perms = zend_hash_str_find(z_arrval_p(entry), zend_strl("

perms

"));

scheme = zend_hash_str_find(z_arrval_p(entry), zend_strl("

scheme

"));

id = zend_hash_str_find(z_arrval_p(entry), zend_strl("id"

));

if (perms == null || scheme == null || id ==null)

convert_to_long_ex(perms);

convert_to_string_ex(scheme);

convert_to_string_ex(id);

aclv->data[i].perms =(int32_t)z_lval_p(perms);

aclv->data[i].id.id =strdup(z_strval_p(id));

aclv->data[i].id.scheme =strdup(z_strval_p(scheme));

i++;

} zend_hash_foreach_end();

#else

for(zend_hash_internal_pointer_reset(z_arrval_p(z_acl));

zend_hash_get_current_data(z_arrval_p(z_acl), (

void**)&entry) ==success;

zend_hash_move_forward(z_arrval_p(z_acl)))

perms = scheme = id =null;

zend_hash_find(z_arrval_pp(entry), zend_strs(

"perms

"), (void**)&perms);

zend_hash_find(z_arrval_pp(entry), zend_strs(

"scheme

"), (void**)&scheme);

zend_hash_find(z_arrval_pp(entry), zend_strs("id

"), (void**)&id);

if (perms == null || scheme == null || id ==null)

convert_to_long_ex(perms);

convert_to_string_ex(scheme);

convert_to_string_ex(id);

aclv->data[i].perms =(int32_t)z_lval_pp(perms);

aclv->data[i].id.id =strdup(z_strval_pp(id));

aclv->data[i].id.scheme =strdup(z_strval_pp(scheme));

i++;

}#endif

aclv->count =i;

}

原始碼裡把acl引數當作陣列的陣列了,所以調整下就可以了:

<?php

$zookeeper = new zookeeper('locahost:2181');

$aclarray = ;

$aclarray = array(

array(

'perms' => zookeeper::perm_all,

'scheme' => 'world',

'id' => 'anyone',

));$path = '/path/to/newnode';

$realpath = $zookeeper->create($path, null, $aclarray);

if ($realpath)

echo $realpath;

else

echo 'err';

?>

axios使用踩坑

1 params和data 1 params params一般用於和url拼接,用於get請求,比如 axios.get user?id 12345 就等價於 axios.get user 2 data data請求是新增在請求體裡的,也就是body中,用於post請求。2 請求頭相關 1 post...

git使用踩坑

1.在本地建立資料夾如c users ykc desktop test 2.開啟git bash進入上面的資料夾。ls cd desktop test 3.使用git init對本地資料夾進行初始化,剩餘步驟依次進行 git init git clone 遠端倉庫鏈結 git mv f oldnam...

Python Sphinx使用踩坑記錄

描述 使用 pip 安裝sphinx後,按照教程建立了乙個新的py檔案,如下 run.py defrun name this is how we run param name name of people who runs print name,is running 隨後新建乙個目錄,使用 sphi...