forked from NationTech/harmony
Switch HAClusterTopology for K8sAnywhereTopology in lamp example
This commit is contained in:
@@ -51,7 +51,7 @@ pub mod tui {
|
||||
/// harmony_tui::init(maestro).await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn init<T: Topology + std::fmt::Debug + Send + Sync + 'static>(
|
||||
pub async fn init<T: Topology + Send + Sync + 'static>(
|
||||
maestro: Maestro<T>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
HarmonyTUI::new(maestro).init().await
|
||||
@@ -63,12 +63,21 @@ pub struct HarmonyTUI<T: Topology> {
|
||||
tui_state: TuiWidgetState,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum HarmonyTuiEvent<T: Topology> {
|
||||
LaunchScore(Box<dyn Score<T>>),
|
||||
}
|
||||
|
||||
impl<T: Topology + std::fmt::Debug + Send + Sync + 'static> HarmonyTUI<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()),
|
||||
};
|
||||
|
||||
f.write_str(&output)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Topology + Send + Sync + 'static> HarmonyTUI<T> {
|
||||
pub fn new(maestro: Maestro<T>) -> Self {
|
||||
let maestro = Arc::new(maestro);
|
||||
let (_handle, sender) = Self::start_channel(maestro.clone());
|
||||
@@ -91,7 +100,7 @@ impl<T: Topology + std::fmt::Debug + Send + Sync + 'static> HarmonyTUI<T> {
|
||||
let handle = tokio::spawn(async move {
|
||||
info!("Starting message channel receiver loop");
|
||||
while let Some(event) = receiver.recv().await {
|
||||
info!("Received event {event:#?}");
|
||||
info!("Received event {event}");
|
||||
match event {
|
||||
HarmonyTuiEvent::LaunchScore(score_item) => {
|
||||
let maestro = maestro.clone();
|
||||
|
||||
Reference in New Issue
Block a user