Initial version of weather microservice

This commit is contained in:
2023-05-07 11:51:01 +02:00
parent 27065dc73d
commit f1698db0e2
12 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
use chrono::{DateTime, Utc};
use influxdb::{Client, InfluxDbWriteable};
use anyhow::Result;
#[derive(InfluxDbWriteable)]
pub struct WeatherReading {
pub time: DateTime<Utc>,
pub wind_speed: f32,
}
pub async fn write_weather_data(
reading: WeatherReading,
base_url: &str,
database: &str,
token: &str,
) -> Result<()> {
let client = Client::new(base_url, database).with_token(token);
let query = reading.into_query("WeatherReading");
client.query(query).await?;
Ok(())
}