churn-v2/crates/churn/src/agent/handlers/scheduled_tasks.rs
kjuulh eeaf59ac63
All checks were successful
continuous-integration/drone/push Build is passing
feat: add comments
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-11-24 22:04:07 +01:00

35 lines
757 B
Rust

use std::collections::BTreeMap;
use crate::agent::actions::Plan;
#[derive(Clone)]
pub struct ScheduledTasks {}
impl ScheduledTasks {
pub fn new() -> Self {
Self {}
}
pub async fn handle(
&self,
task: &str,
_properties: BTreeMap<String, String>,
) -> anyhow::Result<()> {
tracing::info!("scheduling: {}", task);
let plan = Plan::new();
let tasks = plan.tasks().await?;
for task in tasks {
if !task.should_run().await? {
tracing::debug!(task = task.id(), "skipping run");
continue;
}
tracing::info!(task = task.id(), "executing task");
task.execute().await?;
}
Ok(())
}
}