summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRina Fujino <18257209+rina23q@users.noreply.github.com>2022-05-13 02:33:13 +0200
committerRina Fujino <18257209+rina23q@users.noreply.github.com>2022-05-17 14:21:50 +0200
commit8375e5e0be3f006505987c6fc393f013b1a4ed08 (patch)
tree1210c6525ea496953c84133217b9c1f40d8db903
parent60373061fc66f2362eaa6b52c78df4f40f62119d (diff)
Use update notification topic specific for each configuration type
Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
-rw-r--r--plugins/c8y_configuration_plugin/src/download.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/c8y_configuration_plugin/src/download.rs b/plugins/c8y_configuration_plugin/src/download.rs
index 9565cf26..a1b71420 100644
--- a/plugins/c8y_configuration_plugin/src/download.rs
+++ b/plugins/c8y_configuration_plugin/src/download.rs
@@ -15,7 +15,7 @@ use serde_json::json;
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
-use tracing::info;
+use tracing::{info, warn};
const CONFIG_CHANGE_TOPIC: &str = "tedge/configuration_change";
@@ -179,7 +179,12 @@ impl ConfigDownloadRequest {
pub fn get_file_change_notification_message(config_type: String) -> Message {
let notification = json!({ "changedFile": config_type }).to_string();
- Message::new(&Topic::new_unchecked(CONFIG_CHANGE_TOPIC), notification)
+ let topic = Topic::new(format!("{CONFIG_CHANGE_TOPIC}/{config_type}").as_str())
+ .unwrap_or_else(|_err| {
+ warn!("The type cannot be used as a part of the topic name. Using {CONFIG_CHANGE_TOPIC} instead.");
+ Topic::new_unchecked(CONFIG_CHANGE_TOPIC)
+ });
+ Message::new(&topic, notification)
}
struct DownloadConfigFileStatusMessage {}