feat: add common queue
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-11-24 21:08:37 +01:00
parent ee323e99e8
commit ea5adb2f93
15 changed files with 271 additions and 85 deletions

View File

@@ -0,0 +1,36 @@
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<()> {
// Get plan
let plan = Plan::new();
let tasks = plan.tasks().await?;
// For task
for task in tasks {
// Check idempotency rules
if !task.should_run().await? {
tracing::debug!(task = task.id(), "skipping run");
continue;
}
// Run task if not valid
tracing::info!(task = task.id(), "executing task");
task.execute().await?;
}
Ok(())
}
}