feat: Make application async

This commit is contained in:
2026-10-04 05:39:17 +02:00
parent 9440ede0ab
commit bcf716038e
9 changed files with 290 additions and 101 deletions
+29 -20
View File
@@ -16,27 +16,36 @@ pub(crate) struct Patches<T> {
pub(crate) type OptionalPatchesString = OptionalPatches<String>;
fn render(
async fn render(
patches: Vec<String>,
env: &Environment,
env: &Environment<'static>,
cluster: &Cluster,
node: &Node,
) -> Vec<serde_yaml::Value> {
patches
.into_iter()
.map(|name| {
let content = env
.get_template(&name)
.unwrap()
.render(context! {
node,
cluster
})
.unwrap();
let env = env.clone();
let cluster = cluster.clone();
let node = node.clone();
serde_yaml::from_str(&content).unwrap()
})
.collect()
// Minijinja will still have blocking I/O internally
tokio::task::spawn_blocking(move || {
patches
.into_iter()
.map(move |name| {
let content = env
.get_template(&name)
.unwrap()
.render(context! {
node,
cluster
})
.unwrap();
serde_yaml::from_str(&content).unwrap()
})
.collect()
})
.await
.unwrap()
}
impl Patches<String> {
@@ -50,15 +59,15 @@ impl Patches<String> {
}
}
pub(crate) fn render(
pub(crate) async fn render(
self,
env: &Environment,
env: &Environment<'static>,
cluster: &Cluster,
node: &Node,
) -> Patches<serde_yaml::Value> {
Patches {
all: render(self.all.clone(), env, cluster, node),
control_plane: render(self.control_plane.clone(), env, cluster, node),
all: render(self.all.clone(), env, cluster, node).await,
control_plane: render(self.control_plane.clone(), env, cluster, node).await,
}
}
}