From 22847fc42a598f3ed00b5f863d32bf5c71ba6cdc Mon Sep 17 00:00:00 2001 From: Jean-Gabriel Gill-Couture Date: Tue, 24 Jun 2025 11:19:46 -0400 Subject: [PATCH] feat: WIP application module that will allow easy design of application/solution scores with standard delivery features like CI/CD/Backups/Multisite --- harmony/src/modules/application/mod.rs | 83 ++++++++++++++++++++++++++ harmony/src/modules/mod.rs | 1 + 2 files changed, 84 insertions(+) create mode 100644 harmony/src/modules/application/mod.rs diff --git a/harmony/src/modules/application/mod.rs b/harmony/src/modules/application/mod.rs new file mode 100644 index 0000000..54422aa --- /dev/null +++ b/harmony/src/modules/application/mod.rs @@ -0,0 +1,83 @@ +use async_trait::async_trait; +use serde::Serialize; + +use crate::{ + data::{Id, Version}, + interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, + inventory::Inventory, + score::Score, + topology::Topology, +}; + +#[derive(Clone, Serialize, Debug)] +pub struct GoApplicationConfig {} + +#[derive(Clone, Serialize, Debug)] +pub struct GoApplicationScore { + pub config: GoApplicationConfig, +} + +impl Score for GoApplicationScore { + fn create_interpret(&self) -> Box> { + todo!() + } + + fn name(&self) -> String { + todo!() + } +} + +#[derive(Debug)] +pub struct ApplicationInterpret { + pub features: Vec>, +} + +#[async_trait] +impl Interpret for ApplicationInterpret { + async fn execute(&self, _inventory: &Inventory, _topology: &T) -> Result { + todo!() + } + + fn get_name(&self) -> InterpretName { + todo!() + } + + fn get_version(&self) -> Version { + todo!() + } + + fn get_status(&self) -> InterpretStatus { + todo!() + } + + fn get_children(&self) -> Vec { + todo!() + } +} + +/// An ApplicationFeature provided by harmony, such as Backups, Monitoring, MultisiteAvailability, +/// ContinuousIntegration, ContinuousDelivery +#[async_trait] +pub trait ApplicationFeature: std::fmt::Debug + Send + Sync { + async fn ensure_installed(&self) -> Result<(), String>; + async fn is_installed(&self) -> Result; + async fn uninstall(&self) -> Result<(), String>; +} + +#[derive(Debug)] +pub struct BackupFeature; + +#[async_trait] +impl ApplicationFeature for BackupFeature { + async fn ensure_installed(&self) -> Result<(), String> { + todo!() + } + + async fn is_installed(&self) -> Result { + todo!() + } + + async fn uninstall(&self) -> Result<(), String> { + todo!() + } +} diff --git a/harmony/src/modules/mod.rs b/harmony/src/modules/mod.rs index 1427515..465587b 100644 --- a/harmony/src/modules/mod.rs +++ b/harmony/src/modules/mod.rs @@ -14,3 +14,4 @@ pub mod okd; pub mod opnsense; pub mod tenant; pub mod tftp; +pub mod application;