Initial Commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
use sqlx::SqlitePool;
|
||||
use tokio::time::{sleep, Duration};
|
||||
|
||||
use crate::weather::poll_weather;
|
||||
|
||||
pub fn start_weather_scheduler(pool: SqlitePool) {
|
||||
// 3-hour weather poll
|
||||
let pool_3h = pool.clone();
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
if let Err(e) = poll_weather(&pool_3h).await {
|
||||
tracing::error!("Weather poll (3h) failed: {}", e);
|
||||
}
|
||||
sleep(Duration::from_secs(3 * 3600)).await;
|
||||
}
|
||||
});
|
||||
|
||||
// 15-minute dew point poll (open-meteo only)
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
sleep(Duration::from_secs(15 * 60)).await;
|
||||
if let Err(e) = crate::weather::openmeteo::fetch_openmeteo().await {
|
||||
tracing::warn!("Dew point poll failed: {}", e);
|
||||
} else {
|
||||
tracing::debug!("Dew point poll OK");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user