diff options
author | Albin Suresh <albin.suresh@softwareag.com> | 2022-03-31 09:43:53 +0530 |
---|---|---|
committer | Albin Suresh <albin.suresh@softwareag.com> | 2022-03-31 12:13:45 +0530 |
commit | ea8c0d823bf4d9acd22ac9c84d4b2c7a9c273374 (patch) | |
tree | 3a4e138dfadd19c9728057e3bce93234153de227 /crates/core/tedge_agent | |
parent | e55e211586dd72db200df44071631caeed2931c9 (diff) |
Issue #769 Common health check MQTT endpoint for tedge daemons
Diffstat (limited to 'crates/core/tedge_agent')
-rw-r--r-- | crates/core/tedge_agent/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/core/tedge_agent/src/agent.rs | 23 |
2 files changed, 12 insertions, 13 deletions
diff --git a/crates/core/tedge_agent/Cargo.toml b/crates/core/tedge_agent/Cargo.toml index b95a8593..76bde633 100644 --- a/crates/core/tedge_agent/Cargo.toml +++ b/crates/core/tedge_agent/Cargo.toml @@ -37,7 +37,7 @@ tedge_config = { path = "../../common/tedge_config" } tedge_utils = { path = "../../common/tedge_utils", features = ["logging"] } thiserror = "1.0" time = { version = "0.3", features = ["formatting"] } -tokio = { version = "1.8", features = ["fs","process", "rt"] } +tokio = { version = "1.8", features = ["fs","process", "rt", "rt-multi-thread"] } toml = "0.5" tracing = { version = "0.1", features = ["attributes", "log"] } diff --git a/crates/core/tedge_agent/src/agent.rs b/crates/core/tedge_agent/src/agent.rs index 0528cfb9..f5a1be14 100644 --- a/crates/core/tedge_agent/src/agent.rs +++ b/crates/core/tedge_agent/src/agent.rs @@ -8,7 +8,7 @@ use crate::{ }, }; use agent_interface::{ - control_filter_topic, health_check_topic, software_filter_topic, Jsonify, OperationStatus, + control_filter_topic, health_check_topics, software_filter_topic, Jsonify, OperationStatus, RestartOperationRequest, RestartOperationResponse, SoftwareError, SoftwareListRequest, SoftwareListResponse, SoftwareRequestResponse, SoftwareType, SoftwareUpdateRequest, SoftwareUpdateResponse, @@ -40,7 +40,7 @@ const INIT_COMMAND: &str = "echo"; pub struct SmAgentConfig { pub errors_topic: Topic, pub mqtt_config: mqtt_channel::Config, - pub request_topic_health: Topic, + pub request_topics_health: TopicFilter, pub request_topic_list: Topic, pub request_topic_update: Topic, pub request_topics: TopicFilter, @@ -62,15 +62,14 @@ impl Default for SmAgentConfig { let mqtt_config = mqtt_channel::Config::default(); - let request_topics = vec![ - health_check_topic(), - software_filter_topic(), - control_filter_topic(), - ] - .try_into() - .expect("Invalid topic filter"); + let mut request_topics: TopicFilter = vec![software_filter_topic(), control_filter_topic()] + .try_into() + .expect("Invalid topic filter"); - let request_topic_health = Topic::new_unchecked(health_check_topic()); + let request_topics_health: TopicFilter = health_check_topics() + .try_into() + .expect("Invalid topic filter"); + request_topics.add_all(request_topics_health.clone()); let response_topic_health = Topic::new_unchecked("tedge/health/tedge-agent"); @@ -105,7 +104,7 @@ impl Default for SmAgentConfig { Self { errors_topic, mqtt_config, - request_topic_health, + request_topics_health, request_topic_list, request_topic_update, request_topics, @@ -295,7 +294,7 @@ impl SmAgent { while let Some(message) = requests.next().await { debug!("Request {:?}", message); match &message.topic { - topic if topic == &self.config.request_topic_health => { + topic if self.config.request_topics_health.accept_topic(topic) => { let health_message = Message::new(&self.config.response_topic_health, HEALTH_STATUS_UP); let _ = responses.publish(health_message).await; |