Skip to content

Commit

Permalink
fix(#2370): use bridge topic id in service_monitor
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Guzik <[email protected]>
  • Loading branch information
Bravo555 committed Apr 30, 2024
1 parent 0ac3e7e commit ce6e55e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
6 changes: 0 additions & 6 deletions crates/core/tedge_api/src/mqtt_topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,6 @@ impl EntityTopicId {
pub fn as_str(&self) -> &str {
self.0.as_str()
}

// FIXME: can also match "device/bridge//" or "/device/main/service/my_custom_bridge"
// should match ONLY the single mapper bridge
pub fn is_bridge_health_topic(&self) -> bool {
self.as_str().contains("bridge")
}
}

/// Contains a topic id of the service itself and the associated device.
Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/c8y_mapper_ext/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ impl CumulocityConverter {
let ancestors_external_ids =
self.entity_store.ancestors_external_ids(entity_topic_id)?;

if entity_topic_id.is_bridge_health_topic() {
if entity_topic_id == crate::C8Y_BRIDGE_TOPIC_ID {
return Ok(vec![]);
}

Expand Down
2 changes: 2 additions & 0 deletions crates/extensions/c8y_mapper_ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub mod service_monitor;
#[cfg(test)]
mod tests;

pub(crate) const C8Y_BRIDGE_TOPIC_ID: &str = "device/main/service/mosquitto-c8y-bridge";

#[derive(Debug, serde::Deserialize)]
pub struct Capabilities {
log_upload: bool,
Expand Down
3 changes: 2 additions & 1 deletion crates/extensions/c8y_mapper_ext/src/service_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ pub fn convert_health_status_message(
return vec![];
}

if entity.topic_id.is_bridge_health_topic() {
// the bridge itself is not registered as a service, only the mapper
if entity.topic_id == crate::C8Y_BRIDGE_TOPIC_ID {
return vec![];
}

Expand Down

0 comments on commit ce6e55e

Please sign in to comment.