diff --git a/include/neuron/msg.h b/include/neuron/msg.h index fa721f518..9dbfb32b6 100644 --- a/include/neuron/msg.h +++ b/include/neuron/msg.h @@ -305,6 +305,7 @@ typedef struct neu_resp_plugin_info { neu_plugin_kind_e kind; neu_node_type_e type; + uint32_t version; bool single; bool display; diff --git a/plugins/restful/plugin_handle.c b/plugins/restful/plugin_handle.c index b9296636e..745d6d2ce 100644 --- a/plugins/restful/plugin_handle.c +++ b/plugins/restful/plugin_handle.c @@ -143,6 +143,11 @@ void handle_get_plugin_resp(nng_aio *aio, neu_resp_get_plugin_t *plugins) plugin_res.plugin_libs[index].description = (char *) info->description; plugin_res.plugin_libs[index].description_zh = (char *) info->description_zh; + snprintf(plugin_res.plugin_libs[index].version, + sizeof(plugin_res.plugin_libs[index].version), "%d.%d.%d", + NEU_GET_VERSION_MAJOR(info->version), + NEU_GET_VERSION_MINOR(info->version), + NEU_GET_VERSION_FIX(info->version)); } neu_json_encode_by_fn(&plugin_res, neu_json_encode_get_plugin_resp, diff --git a/src/core/plugin_manager.c b/src/core/plugin_manager.c index 15110bbc2..06ffd161b 100644 --- a/src/core/plugin_manager.c +++ b/src/core/plugin_manager.c @@ -42,6 +42,7 @@ typedef struct plugin_entity { neu_plugin_kind_e kind; neu_node_type_e type; + uint32_t version; bool display; @@ -149,6 +150,7 @@ int neu_plugin_manager_add(neu_plugin_manager_t *mgr, } plugin = calloc(1, sizeof(plugin_entity_t)); + plugin->version = pm->version; plugin->display = pm->display; plugin->type = pm->type; plugin->kind = pm->kind; @@ -201,8 +203,9 @@ UT_array *neu_plugin_manager_get(neu_plugin_manager_t *mgr) continue; } neu_resp_plugin_info_t info = { - .kind = el->kind, - .type = el->type, + .kind = el->kind, + .type = el->type, + .version = el->version, }; info.display = el->display; diff --git a/src/parser/neu_json_plugin.c b/src/parser/neu_json_plugin.c index 7c14bf4c2..b9cb39113 100644 --- a/src/parser/neu_json_plugin.c +++ b/src/parser/neu_json_plugin.c @@ -175,6 +175,11 @@ int neu_json_encode_get_plugin_resp(void *json_object, void *param) .t = NEU_JSON_INT, .v.val_int = p_plugin_lib->kind, }, + { + .name = "version", + .t = NEU_JSON_STR, + .v.val_str = p_plugin_lib->version, + }, }; plugin_lib_array = neu_json_encode_array(plugin_lib_array, plugin_lib_elems, diff --git a/src/parser/neu_json_plugin.h b/src/parser/neu_json_plugin.h index e096489b0..0573d8551 100644 --- a/src/parser/neu_json_plugin.h +++ b/src/parser/neu_json_plugin.h @@ -52,6 +52,7 @@ int neu_json_decode_del_plugin_req(char * buf, void neu_json_decode_del_plugin_req_free(neu_json_del_plugin_req_t *req); typedef struct { + char version[32]; char * name; char * schema; char * library;