blob: 4d2e2af201eeaea27ab4c42b6f9472997507d6b2 (
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
35
36
37
38
39
|
use crate::az_converter::AzureConverter;
use crate::component::TEdgeComponent;
use crate::mapper::*;
use crate::size_threshold::SizeThreshold;
use async_trait::async_trait;
use clock::WallClock;
use tedge_config::ConfigSettingAccessor;
use tedge_config::{AzureMapperTimestamp, TEdgeConfig};
use tracing::{info_span, Instrument};
const AZURE_MAPPER_NAME: &str = "tedge-mapper-az";
pub struct AzureMapper {}
impl AzureMapper {
pub fn new() -> AzureMapper {
AzureMapper {}
}
}
#[async_trait]
impl TEdgeComponent for AzureMapper {
async fn start(&self, tedge_config: TEdgeConfig) -> Result<(), anyhow::Error> {
let add_timestamp = tedge_config.query(AzureMapperTimestamp)?.is_set();
let clock = Box::new(WallClock);
let size_threshold = SizeThreshold(255 * 1024);
let converter = Box::new(AzureConverter::new(add_timestamp, clock, size_threshold));
let mut mapper = create_mapper(AZURE_MAPPER_NAME, &tedge_config, converter).await?;
mapper
.run()
.instrument(info_span!(AZURE_MAPPER_NAME))
.await?;
Ok(())
}
}
|