mirror of
https://github.com/emqx/neuron.git
synced 2026-10-21 08:45:47 +08:00
Merge pull request #1028 from eeff/eeff/dev
feat(mqtt): remove upload-topic setting
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user