diff --git a/harmony/src/modules/application/features/continuous_delivery.rs b/harmony/src/modules/application/features/continuous_delivery.rs index 14ce255..cbfdbe7 100644 --- a/harmony/src/modules/application/features/continuous_delivery.rs +++ b/harmony/src/modules/application/features/continuous_delivery.rs @@ -39,4 +39,7 @@ impl ApplicationFeature for ContinuousDelivery { info!("Installing ContinuousDelivery feature"); todo!() } + fn name(&self) -> String { + "ContinuousDelivery".to_string() + } } diff --git a/harmony/src/modules/application/features/endpoint.rs b/harmony/src/modules/application/features/endpoint.rs index 83cc215..042f0dd 100644 --- a/harmony/src/modules/application/features/endpoint.rs +++ b/harmony/src/modules/application/features/endpoint.rs @@ -36,4 +36,7 @@ impl ApplicationFeature for PublicEndpoint ); todo!() } + fn name(&self) -> String { + "PublicEndpoint".to_string() + } } diff --git a/harmony/src/modules/application/features/monitoring.rs b/harmony/src/modules/application/features/monitoring.rs index a343e44..33717a4 100644 --- a/harmony/src/modules/application/features/monitoring.rs +++ b/harmony/src/modules/application/features/monitoring.rs @@ -15,4 +15,7 @@ impl ApplicationFeature for Monitoring { info!("Ensuring monitoring is available for application"); todo!("create and execute k8s prometheus score, depends on Will's work") } + fn name(&self) -> String { + "Monitoring".to_string() + } } diff --git a/harmony/src/modules/application/mod.rs b/harmony/src/modules/application/mod.rs index ddbfe49..663835f 100644 --- a/harmony/src/modules/application/mod.rs +++ b/harmony/src/modules/application/mod.rs @@ -1,9 +1,11 @@ +mod feature; pub mod features; mod rust; +pub use feature::*; +use log::info; pub use rust::*; use async_trait::async_trait; -use serde::Serialize; use crate::{ data::{Id, Version}, @@ -12,9 +14,14 @@ use crate::{ topology::Topology, }; +pub trait Application: std::fmt::Debug + Send + Sync { + fn name(&self) -> String; +} + #[derive(Debug)] pub struct ApplicationInterpret { features: Vec>>, + application: Box, } #[async_trait] @@ -24,7 +31,20 @@ impl Interpret for ApplicationInterpret { _inventory: &Inventory, topology: &T, ) -> Result { + let app_name = self.application.name(); + info!( + "Preparing features {} for application {app_name}", + self.features + .iter() + .map(|f| f.name()) + .collect::>() + .join(", ") + ); for feature in self.features.iter() { + info!( + "Installing feature {} for application {app_name}", + feature.name() + ); let _ = match feature.ensure_installed(topology).await { Ok(()) => (), Err(msg) => { @@ -53,40 +73,3 @@ impl Interpret for ApplicationInterpret { todo!() } } - -/// An ApplicationFeature provided by harmony, such as Backups, Monitoring, MultisiteAvailability, -/// ContinuousIntegration, ContinuousDelivery -#[async_trait] -pub trait ApplicationFeature: - std::fmt::Debug + Send + Sync + ApplicationFeatureClone -{ - async fn ensure_installed(&self, topology: &T) -> Result<(), String>; -} - -trait ApplicationFeatureClone { - fn clone_box(&self) -> Box>; -} - -impl ApplicationFeatureClone for A -where - A: ApplicationFeature + Clone + 'static, -{ - fn clone_box(&self) -> Box> { - Box::new(self.clone()) - } -} - -impl Serialize for Box> { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - todo!() - } -} - -impl Clone for Box> { - fn clone(&self) -> Self { - self.clone_box() - } -} diff --git a/harmony/src/modules/application/rust.rs b/harmony/src/modules/application/rust.rs index 231b821..43a4907 100644 --- a/harmony/src/modules/application/rust.rs +++ b/harmony/src/modules/application/rust.rs @@ -5,7 +5,7 @@ use crate::{ topology::{Topology, Url}, }; -use super::{ApplicationFeature, ApplicationInterpret, features::ContinuousDelivery}; +use super::{Application, ApplicationFeature, ApplicationInterpret}; #[derive(Debug, Serialize, Clone)] pub struct RustWebappScore { @@ -18,6 +18,9 @@ impl Score for R fn create_interpret(&self) -> Box> { Box::new(ApplicationInterpret { features: self.features.clone(), + application: Box::new(RustWebapp { + name: self.name.clone(), + }), }) } @@ -25,3 +28,14 @@ impl Score for R format!("{}-RustWebapp", self.name) } } + +#[derive(Debug)] +struct RustWebapp { + name: String, +} + +impl Application for RustWebapp { + fn name(&self) -> String { + self.name.clone() + } +}