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
All checks were successful
Run Check Script / check (pull_request) Successful in -5s
All checks were successful
Run Check Script / check (pull_request) Successful in -5s
This commit is contained in:
parent
a4aa685a4f
commit
6371009c6f
@ -16,12 +16,16 @@ async fn main() {
|
|||||||
let app = RustWebappScore {
|
let app = RustWebappScore {
|
||||||
name: "Example Rust Webapp".to_string(),
|
name: "Example Rust Webapp".to_string(),
|
||||||
domain: Url::Url(url::Url::parse("https://rustapp.harmony.example.com").unwrap()),
|
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,
|
application,
|
||||||
};
|
};
|
||||||
|
|
||||||
let topology = K8sAnywhereTopology::from_env();
|
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)]);
|
maestro.register_all(vec![Box::new(app)]);
|
||||||
harmony_cli::init(maestro, None).await.unwrap();
|
harmony_cli::init(maestro, None).await.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,10 @@ pub struct Maestro<T: Topology> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Topology> Maestro<T> {
|
impl<T: Topology> Maestro<T> {
|
||||||
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 {
|
Self {
|
||||||
inventory,
|
inventory,
|
||||||
topology,
|
topology,
|
||||||
@ -29,7 +32,7 @@ impl<T: Topology> Maestro<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn initialize(inventory: Inventory, topology: T) -> Result<Self, InterpretError> {
|
pub async fn initialize(inventory: Inventory, topology: T) -> Result<Self, InterpretError> {
|
||||||
let instance = Self::new(inventory, topology);
|
let instance = Self::new_without_initialization(inventory, topology);
|
||||||
instance.prepare_topology().await?;
|
instance.prepare_topology().await?;
|
||||||
Ok(instance)
|
Ok(instance)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
mod feature;
|
mod feature;
|
||||||
pub mod features;
|
pub mod features;
|
||||||
mod rust;
|
|
||||||
pub mod oci;
|
pub mod oci;
|
||||||
|
mod rust;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub use oci::*;
|
|
||||||
pub use feature::*;
|
pub use feature::*;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
pub use oci::*;
|
||||||
pub use rust::*;
|
pub use rust::*;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
@ -153,7 +153,7 @@ mod test {
|
|||||||
fn init_test_maestro() -> Maestro<HAClusterTopology> {
|
fn init_test_maestro() -> Maestro<HAClusterTopology> {
|
||||||
let inventory = Inventory::autoload();
|
let inventory = Inventory::autoload();
|
||||||
let topology = HAClusterTopology::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![
|
maestro.register_all(vec![
|
||||||
Box::new(SuccessScore {}),
|
Box::new(SuccessScore {}),
|
||||||
|
@ -41,7 +41,7 @@ pub mod tui {
|
|||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
/// let inventory = Inventory::autoload();
|
/// let inventory = Inventory::autoload();
|
||||||
/// let topology = HAClusterTopology::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![
|
/// maestro.register_all(vec![
|
||||||
/// Box::new(SuccessScore {}),
|
/// Box::new(SuccessScore {}),
|
||||||
|
Loading…
Reference in New Issue
Block a user