mirror of
https://github.com/emqx/neuron.git
synced 2026-10-18 21:50:42 +08:00
feat(restful): tag read api support synchronous mode
This commit is contained in:
@@ -108,6 +108,7 @@ void neu_json_decode_write_free(neu_json_write_t *req);
|
||||
typedef struct {
|
||||
char *group;
|
||||
char *node;
|
||||
bool sync;
|
||||
} neu_json_read_req_t;
|
||||
|
||||
int neu_json_decode_read_req(char *buf, neu_json_read_req_t **result);
|
||||
|
||||
@@ -43,7 +43,8 @@ void handle_read(nng_aio *aio)
|
||||
|
||||
strcpy(cmd.driver, req->node);
|
||||
strcpy(cmd.group, req->group);
|
||||
ret = neu_plugin_op(plugin, header, &cmd);
|
||||
cmd.sync = req->sync;
|
||||
ret = neu_plugin_op(plugin, header, &cmd);
|
||||
if (ret != 0) {
|
||||
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
|
||||
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
|
||||
|
||||
@@ -413,14 +413,21 @@ int neu_json_decode_read_req(char *buf, neu_json_read_req_t **result)
|
||||
|
||||
json_obj = neu_json_decode_new(buf);
|
||||
|
||||
neu_json_elem_t req_elems[] = { {
|
||||
.name = "node",
|
||||
.t = NEU_JSON_STR,
|
||||
},
|
||||
{
|
||||
.name = "group",
|
||||
.t = NEU_JSON_STR,
|
||||
} };
|
||||
neu_json_elem_t req_elems[] = {
|
||||
{
|
||||
.name = "node",
|
||||
.t = NEU_JSON_STR,
|
||||
},
|
||||
{
|
||||
.name = "group",
|
||||
.t = NEU_JSON_STR,
|
||||
},
|
||||
{
|
||||
.name = "sync",
|
||||
.t = NEU_JSON_BOOL,
|
||||
.attribute = NEU_JSON_ATTRIBUTE_OPTIONAL,
|
||||
},
|
||||
};
|
||||
ret = neu_json_decode_by_json(json_obj, NEU_JSON_ELEM_SIZE(req_elems),
|
||||
req_elems);
|
||||
if (ret != 0) {
|
||||
@@ -429,6 +436,7 @@ int neu_json_decode_read_req(char *buf, neu_json_read_req_t **result)
|
||||
|
||||
req->node = req_elems[0].v.val_str;
|
||||
req->group = req_elems[1].v.val_str;
|
||||
req->sync = req_elems[2].v.val_bool;
|
||||
|
||||
*result = req;
|
||||
goto decode_exit;
|
||||
|
||||
Reference in New Issue
Block a user