mirror of
https://github.com/emqx/neuron.git
synced 2026-10-18 13:41:22 +08:00
Add functions for notifying tags event
1. Add neu_plugin_notify_event_add_tags 2. Add neu_plugin_notify_event_del_tags 3. Add neu_plugin_notify_event_update_tags
This commit is contained in:
@@ -374,6 +374,11 @@ typedef struct neu_event_reply {
|
||||
void * buf;
|
||||
} neu_event_reply_t;
|
||||
|
||||
typedef struct neu_event_tags {
|
||||
neu_node_id_t node_id;
|
||||
char * grp_config_name;
|
||||
} neu_event_tags_t;
|
||||
|
||||
/**
|
||||
* definition enum and structure for neuron config
|
||||
*/
|
||||
|
||||
@@ -122,6 +122,17 @@ const char * neu_plugin_self_node_name(neu_plugin_t *plugin);
|
||||
|
||||
intptr_t neu_system_add_plugin(neu_plugin_t *plugin,
|
||||
const char * plugin_lib_name);
|
||||
|
||||
int neu_plugin_notify_event_add_tags(neu_plugin_t *plugin, uint32_t event_id,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name);
|
||||
int neu_plugin_notify_event_del_tags(neu_plugin_t *plugin, uint32_t event_id,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name);
|
||||
int neu_plugin_notify_event_update_tags(neu_plugin_t *plugin, uint32_t event_id,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name);
|
||||
|
||||
intptr_t neu_system_del_plugin(neu_plugin_t *plugin, plugin_id_t plugin_id);
|
||||
intptr_t neu_system_update_plugin(neu_plugin_t *plugin, plugin_kind_e kind,
|
||||
neu_node_type_e node_type,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "neu_errcodes.h"
|
||||
#include "neu_plugin.h"
|
||||
|
||||
#define NEU_PLUGIN_MAGIC_NUMBER 0x43474d50 // a string "PMGC"
|
||||
@@ -300,6 +301,56 @@ void neu_plugin_send_write_cmd(neu_plugin_t *plugin, uint32_t event_id,
|
||||
PLUGIN_SEND_CMD(plugin, NEU_REQRESP_WRITE_DATA, write_req, event_id)
|
||||
}
|
||||
|
||||
static inline int plugin_notify_tags_event(neu_plugin_t * plugin,
|
||||
uint32_t event_id,
|
||||
neu_event_type_e type,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name)
|
||||
{
|
||||
neu_event_tags_t tags_event = {
|
||||
.node_id = node_id,
|
||||
.grp_config_name = strdup(grp_config_name),
|
||||
};
|
||||
|
||||
if (NULL == tags_event.grp_config_name) {
|
||||
return NEU_ERR_ENOMEM;
|
||||
}
|
||||
|
||||
neu_event_notify_t event = {
|
||||
.event_id = event_id,
|
||||
.type = type,
|
||||
.buf = &tags_event,
|
||||
.buf_len = sizeof(tags_event),
|
||||
};
|
||||
neu_plugin_common_t *plugin_common = neu_plugin_to_plugin_common(plugin);
|
||||
return plugin_common->adapter_callbacks->event_notify(
|
||||
plugin_common->adapter, &event);
|
||||
}
|
||||
|
||||
int neu_plugin_notify_event_add_tags(neu_plugin_t *plugin, uint32_t event_id,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name)
|
||||
{
|
||||
return plugin_notify_tags_event(plugin, event_id, NEU_EVENT_ADD_TAGS,
|
||||
node_id, grp_config_name);
|
||||
}
|
||||
|
||||
int neu_plugin_notify_event_del_tags(neu_plugin_t *plugin, uint32_t event_id,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name)
|
||||
{
|
||||
return plugin_notify_tags_event(plugin, event_id, NEU_EVENT_DEL_TAGS,
|
||||
node_id, grp_config_name);
|
||||
}
|
||||
|
||||
int neu_plugin_notify_event_update_tags(neu_plugin_t *plugin, uint32_t event_id,
|
||||
neu_node_id_t node_id,
|
||||
const char * grp_config_name)
|
||||
{
|
||||
return plugin_notify_tags_event(plugin, event_id, NEU_EVENT_UPDATE_TAGS,
|
||||
node_id, grp_config_name);
|
||||
}
|
||||
|
||||
void neu_plugin_response_trans_data(neu_plugin_t * plugin,
|
||||
neu_taggrp_config_t *grp_config,
|
||||
neu_data_val_t *data, uint32_t event_id)
|
||||
|
||||
Reference in New Issue
Block a user