feat: Introduce Topology Trait for Compile-Time Safe Score Binding

Introduce the `Topology` trait to ensure that `Maestro` can compile-time safely bind compatible `Scores` and `Topologies`. This refactoring includes updating `HarmonyTuiEvent`, `ScoreListWidget`, and related structures to work with generic `Topology` types, enhancing type safety and modularity.
This commit is contained in:
2025-04-02 15:51:28 -04:00
parent f7dc15cbf0
commit fc718f11cf
9 changed files with 87 additions and 64 deletions

View File

@@ -8,7 +8,7 @@ publish = false
[dependencies]
harmony = { path = "../../harmony" }
harmony_tui = { path = "../../harmony_tui" }
#harmony_tui = { path = "../../harmony_tui" }
harmony_types = { path = "../../harmony_types" }
cidr = { workspace = true }
tokio = { workspace = true }

View File

@@ -2,7 +2,8 @@ use harmony::{
data::Version,
maestro::Maestro,
modules::lamp::{LAMPConfig, LAMPScore},
topology::Url,
score::Score,
topology::{HAClusterTopology, Topology, Url},
};
#[tokio::main]
@@ -17,8 +18,12 @@ async fn main() {
},
};
Maestro::load_from_env()
Maestro::<HAClusterTopology>::load_from_env()
.interpret(Box::new(lamp_stack))
.await
.unwrap();
}
fn clone_score<T: Topology, S: Score<T> + Clone + 'static>(score: S) -> Box<S> {
Box::new(score.clone())
}

View File

@@ -1,7 +1,10 @@
use harmony::{
inventory::Inventory,
maestro::Maestro,
modules::{dummy::{ErrorScore, PanicScore, SuccessScore}, k8s::deployment::K8sDeploymentScore},
modules::{
dummy::{ErrorScore, PanicScore, SuccessScore},
k8s::deployment::K8sDeploymentScore,
},
topology::HAClusterTopology,
};