Skip to content

Commit 98ccfe7

Browse files
committed
fix(#2370): use bridge topic id in service_monitor
Signed-off-by: Marcel Guzik <[email protected]>
1 parent 0ac3e7e commit 98ccfe7

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

crates/core/tedge_api/src/mqtt_topics.rs

-6
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,6 @@ impl EntityTopicId {
390390
pub fn as_str(&self) -> &str {
391391
self.0.as_str()
392392
}
393-
394-
// FIXME: can also match "device/bridge//" or "/device/main/service/my_custom_bridge"
395-
// should match ONLY the single mapper bridge
396-
pub fn is_bridge_health_topic(&self) -> bool {
397-
self.as_str().contains("bridge")
398-
}
399393
}
400394

401395
/// Contains a topic id of the service itself and the associated device.

crates/extensions/c8y_mapper_ext/src/converter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl CumulocityConverter {
340340
let ancestors_external_ids =
341341
self.entity_store.ancestors_external_ids(entity_topic_id)?;
342342

343-
if entity_topic_id.is_bridge_health_topic() {
343+
if entity_topic_id == crate::C8Y_BRIDGE_TOPIC_ID {
344344
return Ok(vec![]);
345345
}
346346

crates/extensions/c8y_mapper_ext/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub mod service_monitor;
1414
#[cfg(test)]
1515
mod tests;
1616

17+
pub(crate) const C8Y_BRIDGE_TOPIC_ID: &str = "device/main/service/mosquitto-c8y-bridge";
18+
1719
#[derive(Debug, serde::Deserialize)]
1820
pub struct Capabilities {
1921
log_upload: bool,

crates/extensions/c8y_mapper_ext/src/service_monitor.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub fn convert_health_status_message(
2828
return vec![];
2929
}
3030

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

@@ -128,6 +129,14 @@ mod tests {
128129
r#"102,test_device:device:main:service:tedge-mapper-c8y,service,tedge-mapper-c8y,"up""down""#;
129130
"service-monitoring-double-quotes-health-message"
130131
)]
132+
#[test_case(
133+
"test_device",
134+
"te/device/main/service/my-bridge/status/health",
135+
r#"{"pid":"1234","status":"up"}"#,
136+
"c8y/s/us",
137+
r#"102,test_device:device:main:service:my-bridge,service,my-bridge,up"#;
138+
"service-monitoring-service-with-bridge-in-name"
139+
)]
131140
fn translate_health_status_to_c8y_service_monitoring_message(
132141
device_name: &str,
133142
health_topic: &str,

0 commit comments

Comments
 (0)