diff options
author | PradeepKiruvale <pradeepkumar.kj@softwareag.com> | 2022-03-24 13:35:38 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 13:35:38 +0530 |
commit | 59142ef60484ddc7b103c841d34b308b9444f316 (patch) | |
tree | d7b8f89179d2244a1e116081b11a28e7c3a141fa /crates/core/tedge_mapper/src/az/mapper.rs | |
parent | d9ca6aedfad3de7931964200f26e40fdd577b48a (diff) |
[#761] tedge init (#993)
* tedge init #Closes 761
* add file/directory creation errors
* add the clear session to az and collectd mappers
* refactor tedgecomponent
* remove redundant code
* subscribe to az/collectd topics in init_session
* remove duplicate init_sessions
Diffstat (limited to 'crates/core/tedge_mapper/src/az/mapper.rs')
-rw-r--r-- | crates/core/tedge_mapper/src/az/mapper.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/core/tedge_mapper/src/az/mapper.rs b/crates/core/tedge_mapper/src/az/mapper.rs index 542e6c1c..0d998eff 100644 --- a/crates/core/tedge_mapper/src/az/mapper.rs +++ b/crates/core/tedge_mapper/src/az/mapper.rs @@ -7,7 +7,8 @@ use async_trait::async_trait; use clock::WallClock; use tedge_config::{AzureMapperTimestamp, MqttBindAddressSetting, TEdgeConfig}; use tedge_config::{ConfigSettingAccessor, MqttPortSetting}; -use tracing::{info_span, Instrument}; +use tedge_utils::file::create_directory_with_user_group; +use tracing::{info, info_span, Instrument}; const AZURE_MAPPER_NAME: &str = "tedge-mapper-az"; @@ -21,6 +22,23 @@ impl AzureMapper { #[async_trait] impl TEdgeComponent for AzureMapper { + fn session_name(&self) -> &str { + AZURE_MAPPER_NAME + } + + async fn init(&self) -> Result<(), anyhow::Error> { + info!("Initialize tedge mapper az"); + create_directory_with_user_group( + "/etc/tedge/operations/az", + "tedge-mapper", + "tedge-mapper", + 0o775, + )?; + + self.init_session(AzureConverter::in_topic_filter()).await?; + Ok(()) + } + async fn start(&self, tedge_config: TEdgeConfig) -> Result<(), anyhow::Error> { let add_timestamp = tedge_config.query(AzureMapperTimestamp)?.is_set(); let mqtt_port = tedge_config.query(MqttPortSetting)?.into(); |