From 6371009c6fd6c28423323686eaebd493cc9fae81 Mon Sep 17 00:00:00 2001 From: Jean-Gabriel Gill-Couture Date: Wed, 2 Jul 2025 17:47:23 -0400 Subject: [PATCH] breaking: Rename Maestro::new to Maestro::new_without_initialization. This improves UX as it makes it more obvious to users that this method should rarely be used --- examples/rust/src/main.rs | 8 ++++++-- harmony/src/domain/maestro/mod.rs | 7 +++++-- harmony/src/modules/application/mod.rs | 4 ++-- harmony_cli/src/lib.rs | 2 +- harmony_tui/src/lib.rs | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/rust/src/main.rs b/examples/rust/src/main.rs index 4ecf604..15d35f1 100644 --- a/examples/rust/src/main.rs +++ b/examples/rust/src/main.rs @@ -16,12 +16,16 @@ async fn main() { let app = RustWebappScore { name: "Example Rust Webapp".to_string(), domain: Url::Url(url::Url::parse("https://rustapp.harmony.example.com").unwrap()), - features: vec![Box::new(ContinuousDelivery { application: Arc::new(application.clone()) })], + features: vec![Box::new(ContinuousDelivery { + application: Arc::new(application.clone()), + })], application, }; let topology = K8sAnywhereTopology::from_env(); - let mut maestro = Maestro::initialize(Inventory::autoload(), topology).await.unwrap(); + let mut maestro = Maestro::initialize(Inventory::autoload(), topology) + .await + .unwrap(); maestro.register_all(vec![Box::new(app)]); harmony_cli::init(maestro, None).await.unwrap(); } diff --git a/harmony/src/domain/maestro/mod.rs b/harmony/src/domain/maestro/mod.rs index f28b1dd..8a90eed 100644 --- a/harmony/src/domain/maestro/mod.rs +++ b/harmony/src/domain/maestro/mod.rs @@ -19,7 +19,10 @@ pub struct Maestro { } impl Maestro { - fn new(inventory: Inventory, topology: T) -> Self { + /// Creates a bare maestro without initialization. + /// + /// This should rarely be used. Most of the time Maestro::initialize should be used instead. + pub fn new_without_initialization(inventory: Inventory, topology: T) -> Self { Self { inventory, topology, @@ -29,7 +32,7 @@ impl Maestro { } pub async fn initialize(inventory: Inventory, topology: T) -> Result { - let instance = Self::new(inventory, topology); + let instance = Self::new_without_initialization(inventory, topology); instance.prepare_topology().await?; Ok(instance) } diff --git a/harmony/src/modules/application/mod.rs b/harmony/src/modules/application/mod.rs index 9851e6e..c43e901 100644 --- a/harmony/src/modules/application/mod.rs +++ b/harmony/src/modules/application/mod.rs @@ -1,12 +1,12 @@ mod feature; pub mod features; -mod rust; pub mod oci; +mod rust; use std::sync::Arc; -pub use oci::*; pub use feature::*; use log::info; +pub use oci::*; pub use rust::*; use async_trait::async_trait; diff --git a/harmony_cli/src/lib.rs b/harmony_cli/src/lib.rs index 50beb6e..52b59e0 100644 --- a/harmony_cli/src/lib.rs +++ b/harmony_cli/src/lib.rs @@ -153,7 +153,7 @@ mod test { fn init_test_maestro() -> Maestro { let inventory = Inventory::autoload(); let topology = HAClusterTopology::autoload(); - let mut maestro = Maestro::new(inventory, topology); + let mut maestro = Maestro::new_without_initialization(inventory, topology); maestro.register_all(vec![ Box::new(SuccessScore {}), diff --git a/harmony_tui/src/lib.rs b/harmony_tui/src/lib.rs index 180d608..4a807ff 100644 --- a/harmony_tui/src/lib.rs +++ b/harmony_tui/src/lib.rs @@ -41,7 +41,7 @@ pub mod tui { /// async fn main() { /// let inventory = Inventory::autoload(); /// let topology = HAClusterTopology::autoload(); -/// let mut maestro = Maestro::new(inventory, topology); +/// let mut maestro = Maestro::new_without_initialization(inventory, topology); /// /// maestro.register_all(vec![ /// Box::new(SuccessScore {}),