feat: introduce topology readiness and initialization #10

Merged
johnride merged 12 commits from feat/topologyDependencies into master 2025-04-23 15:58:32 +00:00
23 changed files with 1349 additions and 58 deletions
Showing only changes of commit 45668638e1 - Show all commits

View File

@@ -17,7 +17,7 @@ async fn main() {
},
};
let maestro = Maestro::<K8sAnywhereTopology>::load_from_env();
let mut maestro = Maestro::<K8sAnywhereTopology>::load_from_env();
maestro.register_all(vec![Box::new(lamp_stack)]);
harmony_tui::init(maestro).await.unwrap();
}

View File

@@ -22,7 +22,6 @@ async fn main() {
let topology = HAClusterTopology::autoload();
let mut maestro = Maestro::new(inventory, topology);
maestro.register_all(vec![
Box::new(SuccessScore {}),
Box::new(ErrorScore {}),

View File

@@ -67,10 +67,10 @@ enum HarmonyTuiEvent<T: Topology> {
LaunchScore(Box<dyn Score<T>>),
}
impl <T: Topology> std::fmt::Display for HarmonyTuiEvent<T> {
impl<T: Topology> std::fmt::Display for HarmonyTuiEvent<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let output = match self {
HarmonyTuiEvent::LaunchScore(score) => format!("LaunchScore({})",score.name()),
HarmonyTuiEvent::LaunchScore(score) => format!("LaunchScore({})", score.name()),
};
f.write_str(&output)

View File

@@ -19,13 +19,21 @@ enum ExecutionState {
CANCELED,
}
#[derive(Debug)]
struct Execution<T: Topology> {
state: ExecutionState,
score: Box<dyn Score<T>>,
}
#[derive(Debug)]
impl<T: Topology> std::fmt::Display for Execution<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"Execution of {} status {:?}",
self.score.name(),
self.state
))
}
}
pub(crate) struct ScoreListWidget<T: Topology> {
list_state: Arc<RwLock<ListState>>,
scores: Vec<Box<dyn Score<T>>>,
@@ -34,7 +42,7 @@ pub(crate) struct ScoreListWidget<T: Topology> {
sender: mpsc::Sender<HarmonyTuiEvent<T>>,
}
impl<T: Topology + std::fmt::Debug> ScoreListWidget<T> {
impl<T: Topology> ScoreListWidget<T> {
pub(crate) fn new(
scores: Vec<Box<dyn Score<T>>>,
sender: mpsc::Sender<HarmonyTuiEvent<T>>,
@@ -99,7 +107,7 @@ impl<T: Topology + std::fmt::Debug> ScoreListWidget<T> {
match confirm {
true => {
execution.state = ExecutionState::RUNNING;
info!("Launch execution {:?}", execution);
info!("Launch execution {execution}");
self.sender
.send(HarmonyTuiEvent::LaunchScore(execution.score.clone_box()))
.await