Skip to content

Commit

Permalink
Merge pull request #1687 from ZhouBox/main
Browse files Browse the repository at this point in the history
feat(api):add version when get plugins info
  • Loading branch information
fengzeroz authored Nov 21, 2023
2 parents a45e2d8 + 603e3d8 commit ac50ee2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/neuron/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions plugins/restful/plugin_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions src/core/plugin_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ typedef struct plugin_entity {

neu_plugin_kind_e kind;
neu_node_type_e type;
uint32_t version;

bool display;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/parser/neu_json_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/parser/neu_json_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ac50ee2

Please sign in to comment.