-
Notifications
You must be signed in to change notification settings - Fork 536
QConf C\Cpp Doc
int qconf_init();
Description
Initial qconf environment
Parameters
Return Value**
QCONF_OK if success, others if failed.
Example
int ret = qconf_init();
int qconf_destroy();
Description
destroy qconf environment
Parameters
Return Value
Example
qconf_destroy();
int qconf_get_conf(const char *path, char *buf, unsigned int buf_len, const char *idc);
Description
get configure value
Parameters
path - key of configuration.
buf - out parameter, buffer for value
buf_len - lenghth of value buffer
idc - from which idc to get the value,get from local idc if idc is NULL
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_NOT_FOUND if configuration is not exists
Example
char value[QCONF_CONF_BUF_MAX_LEN];
int ret = qconf_get_conf("demo/conf1", value, sizeof(value), NULL);
assert(QCONF_OK == ret);
int qconf_get_batch_keys(const char *path, string_vector_t *nodes, const char *idc);
Description
get all children nodes'key
Parameters
path - key of configuration.
nodes - out parameter, keep all children nodes'key
idc - from which idc to get the keys,get from local idc if idc is NULL
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_NOT_FOUND if not exists
Example
string_vector_t bnodes_key;
init_string_vector(&bnodes_key);
int ret = qconf_get_batch_keys(path, &bnodes_key, NULL);
assert(QCONF_OK == ret);
for (i = 0; i < bnodes_key.count; i++)
{ cout << bnodes_key.data[i] << endl;}
destroy_string_vector(&bnodes_key);
int qconf_get_batch_conf(const char *path, string_vector_t *nodes, const char *idc);
Description
get all children nodes' key and value
Parameters
path - key of configuration.
nodes - out parameter, keep all children nodes' key and value
idc - from which idc to get the children configurations,get from local idc if idc is NULL
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_NOT_FOUND if not exists
Example
qconf_batch_nodes bnodes;
init_qconf_batch_nodes(&bnodes);
int ret = qconf_get_batch_conf(path, &bnodes, NULL);
assert(QCONF_OK == ret);
for (i = 0; i < bnodes.count; i++)
{cout << bnodes.nodes[i].key << " : " << bnodes.nodes[i].value;}
destroy_qconf_batch_nodes(&bnodes);
int qconf_get_allhost(const char *path, string_vector_t *nodes, const char *idc);
Description
get all available services under given path
Parameters
path - key of configuration.
nodes - out parameter, keep all available services
idc - from which idc to get the services,get from local idc if idc is NULL
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_NOT_FOUND if not exists
Example
string_vector_t nodes;
init_string_vector(&nodes);
int ret = qconf_get_batch_conf(path, &nodes, NULL);
assert(QCONF_OK == ret);
for (i = 0; i < nodes.count; i++)
{cout << nodes.data[i] << endl;}
destroy_string_vector(&nodes_key);
int qconf_get_host(const char *path, char *buf, unsigned int buf_len, const char *idc);
Description
get one available service
Parameters
path - key of configuration.
buf - out parameter, keep the service
buf_len - lenghth of buf
idc - from which idc to get the value,get from local idc if idc is NULL
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_NOT_FOUND if configuration is not exists
Example
char host[QCONF_HOST_BUF_MAX_LEN] = {0};
int ret = qconf_get_host(path, host, sizeof(host), NULL);
assert(QCONF_OK == ret);
typedef struct
{
int count; // the number of services
char **data; // the array of services
} string_vector_t;
int init_string_vector(string_vector_t *nodes);
Description
initial array for keeping services
Tips: the function should be called before calling qconf_get_batchkeys or qconf_get_allhosts
Parameters
nodes - out parameter, the array for keeping batch keys or services
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_PARAM if nodes is null
Example
string_vector_t bnodes_key;
init_string_vector(&bnodes_key);
int destroy_string_vector(string_vector_t *nodes);
Description
destroy the array for keeping batch keys or services
Tips: remember to call this function after the last use of string_vector_t
Parameters
nodes - out parameter, qconf_batch_nodes keeping batch keys or services
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_PARAM if nodes is null
Example
qconf_batch_nodes nodes;
destroy_string_vector(&nodes);
typedef struct qconf_node
{
char *key;
char *value;
} qconf_node;
typedef struct qconf_batch_nodes
{
int count;
qconf_node *nodes;
} qconf_batch_nodes;
int init_qconf_batch_nodes(qconf_batch_nodes *bnodes);
Description
initial nodes array for keeping batch conf
Tips: the function should be called before calling qconf_get_batchconf
Parameters
bnodes - out parameter, qconf_batch_nodes to keeping batch nodes
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_PARAM if nodes is null
Example
qconf_batch_nodes bnodes;
init_qconf_batch_nodes(&bnodes);
int destroy_qconf_batch_nodes(qconf_batch_nodes *bnodes);
Description
destroy the nodes array for keeping batch conf
Tips: remember to call this function after the last use of qconf_batch_nodes
Parameters
bnodes - out parameter, qconf_batch_nodes keeping batch nodes
Return Value
QCONF_OK if success, others if failed. QCONF_ERR_PARAM if nodes is null
Example
qconf_batch_nodes bnodes;
destroy_qconf_batch_nodes(&bnodes);
qconf command key [idc]
command: can be one of below commands:
get_conf : get configure value
get_host : get one service
get_allhost : get all services available
get_batch_keys : get all children keys
key : the path of your configure items
idc : query from current idc if be omitted
qconf get_conf "demo/conf"
qconf get_conf "demo/conf" "test"
qconf get_host "demo/hosts"
qconf get_host "demo/hosts" "test"
qconf get_allhost "demo/hosts"
qconf get_allhost "demo/hosts" "test"
qconf get_conf "demo/batch"
qconf get_conf "demo/batch" "test"
- QConf Wiki
- FAQ
- Nginx 配置文件 脚本更新说明
- QConf 保证数据的正确性方法
- QConf 使用场景
- QConf 反馈服务器简单示例
- QConf 架构
- QConf 灰度发布功能说明
- QConf 简易部署和使用
- QConf monitor简易部署使用
- QConf Document
- QConf C\C++ Doc
- QConf Go Doc
- QConf Java Doc
- QConf LuaJit Doc
- QConf Node Doc
- QConf Perl Doc
- QConf PHP Doc
- QConf Python Doc
- QConf 管理端
- QConf 管理界面使用
- QConf 管理端接口(C )
- QConf 管理端接口(PHP)