From 07f66717f4a3598116fd9678f3c5646ed7e00182 Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Tue, 10 Jan 2023 23:37:17 +0800 Subject: [PATCH] feat(mqtt): remove upload-topic setting --- plugins/mqtt/mqtt.json | 10 ---------- plugins/mqtt/mqtt_config.c | 21 ++++----------------- plugins/mqtt/mqtt_config.h | 1 - 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/plugins/mqtt/mqtt.json b/plugins/mqtt/mqtt.json index 5d007df0..37293dd1 100644 --- a/plugins/mqtt/mqtt.json +++ b/plugins/mqtt/mqtt.json @@ -9,16 +9,6 @@ "length": 255 } }, - "upload-topic": { - "name": "upload topic", - "description": "Topic to which publish tags data.", - "type": "string", - "attribute": "required", - "default": "/neuron/${node-name}/upload", - "valid": { - "length": 255 - } - }, "format": { "name": "upload format", "description": "JSON format of the data reported in the upload topic. In values mode, data are split into `values` and `errors` sub objects. In tags mode, tag data are put in a single array.", diff --git a/plugins/mqtt/mqtt_config.c b/plugins/mqtt/mqtt_config.c index e6f5b9f9..8f3b78b7 100644 --- a/plugins/mqtt/mqtt_config.c +++ b/plugins/mqtt/mqtt_config.c @@ -123,8 +123,6 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, const char *placeholder = "********"; neu_json_elem_t client_id = { .name = "client-id", .t = NEU_JSON_STR }; - neu_json_elem_t upload_topic = { .name = "upload-topic", - .t = NEU_JSON_STR }; neu_json_elem_t format = { .name = "format", .t = NEU_JSON_INT }; neu_json_elem_t cache_mem_size = { .name = "cache-mem-size", .t = NEU_JSON_INT }; @@ -145,9 +143,8 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, return -1; } - ret = neu_parse_param(setting, &err_param, 7, &client_id, &upload_topic, - &format, &cache_mem_size, &cache_disk_size, &host, - &port); + ret = neu_parse_param(setting, &err_param, 6, &client_id, &format, + &cache_mem_size, &cache_disk_size, &host, &port); if (0 != ret) { plog_error(plugin, "parsing setting fail, key: `%s`", err_param); goto error; @@ -159,12 +156,6 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, goto error; } - // upload-topic, required - if (0 == strlen(upload_topic.v.val_str)) { - plog_error(plugin, "setting empty upload-topic"); - goto error; - } - // format, required if (MQTT_UPLOAD_FORMAT_VALUES != format.v.val_int && MQTT_UPLOAD_FORMAT_TAGS != format.v.val_int) { @@ -231,9 +222,8 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, goto error; } - config->client_id = client_id.v.val_str; - config->upload_topic = upload_topic.v.val_str; - config->format = format.v.val_int; + config->client_id = client_id.v.val_str; + config->format = format.v.val_int; config->cache = 0 != cache_mem_size.v.val_int || 0 != cache_disk_size.v.val_int; config->cache_mem_size = cache_mem_size.v.val_int * MB; @@ -248,7 +238,6 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, config->keypass = keypass.v.val_str; plog_info(plugin, "config client-id : %s", config->client_id); - plog_info(plugin, "config upload-topic : %s", config->upload_topic); plog_info(plugin, "config format : %s", mqtt_upload_format_str(config->format)); plog_info(plugin, "config cache : %zu", config->cache); @@ -281,7 +270,6 @@ int mqtt_config_parse(neu_plugin_t *plugin, const char *setting, error: free(err_param); - free(upload_topic.v.val_str); free(host.v.val_str); free(username.v.val_str); free(password.v.val_str); @@ -295,7 +283,6 @@ error: void mqtt_config_fini(mqtt_config_t *config) { free(config->client_id); - free(config->upload_topic); free(config->host); free(config->username); free(config->password); diff --git a/plugins/mqtt/mqtt_config.h b/plugins/mqtt/mqtt_config.h index 2efa07bd..bf9ae02c 100644 --- a/plugins/mqtt/mqtt_config.h +++ b/plugins/mqtt/mqtt_config.h @@ -48,7 +48,6 @@ static inline const char *mqtt_upload_format_str(mqtt_upload_format_e f) typedef struct { char * client_id; // client id - char * upload_topic; // upload topic mqtt_upload_format_e format; // upload format size_t cache; // cache enable flag size_t cache_mem_size; // cache memory size in bytes