blob: aac2b087cfe067a1efd220d9c2e81cc8b2728112 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use crate::{
collectd::monitor::{DeviceMonitor, DeviceMonitorConfig},
core::component::TEdgeComponent,
};
use async_trait::async_trait;
use tedge_config::{ConfigSettingAccessor, MqttPortSetting, TEdgeConfig};
use tracing::{info_span, Instrument};
const APP_NAME: &str = "tedge-mapper-collectd";
pub struct CollectdMapper {}
impl CollectdMapper {
pub fn new() -> Self {
Self {}
}
}
#[async_trait]
impl TEdgeComponent for CollectdMapper {
async fn start(&self, tedge_config: TEdgeConfig) -> Result<(), anyhow::Error> {
let mqtt_port = tedge_config.query(MqttPortSetting)?.into();
let device_monitor_config = DeviceMonitorConfig::default().with_port(mqtt_port);
let device_monitor = DeviceMonitor::new(device_monitor_config);
device_monitor
.run()
.instrument(info_span!(APP_NAME))
.await?;
Ok(())
}
}
|