feat: add load balancer score and frontend integration

- Implemented `OKDLoadBalancerScore` and integrated it as a `FrontendScore`.
- Added `FrontendScore` trait for TUI displayable scores.
- Implemented `Display` for `OKDLoadBalancerScore`.
- Updated `ScoreListWidget` to handle `FrontendScore` types.
- Included load balancer score in the TUI.
This commit is contained in:
2025-04-03 13:41:29 -04:00
parent e6384da57e
commit ab9b7476a4
8 changed files with 27 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
use std::sync::{Arc, RwLock};
use crossterm::event::{Event, KeyCode, KeyEventKind};
use harmony::{score::Score, topology::Topology};
use harmony::{modules::okd::load_balancer::OKDLoadBalancerScore, score::Score, topology::{LoadBalancer, Topology}};
use log::{info, warn};
use ratatui::{
layout::Rect, style::{Style, Stylize}, widgets::{List, ListItem, ListState, StatefulWidget, Widget}, Frame
@@ -23,10 +23,12 @@ struct Execution<T: Topology> {
score: Box<dyn Score<T>>,
}
impl <T: Topology + LoadBalancer> FrontendScore<T> for OKDLoadBalancerScore {}
#[derive(Debug)]
pub(crate) struct ScoreListWidget<T: Topology> {
list_state: Arc<RwLock<ListState>>,
scores: Vec<Box<dyn Score<T>>>,
scores: Vec<Box<dyn FrontendScore<T>>>,
execution: Option<Execution<T>>,
execution_history: Vec<Execution<T>>,
sender: mpsc::Sender<HarmonyTuiEvent<T>>,