feat: Application module architecture and placeholder features #70

Merged
letian merged 11 commits from feat/applicationModule into master 2025-07-01 19:40:43 +00:00
2 changed files with 84 additions and 0 deletions
Showing only changes of commit 22847fc42a - Show all commits

View File

@ -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<T: Topology> Score<T> for GoApplicationScore {
fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> {
todo!()
}
fn name(&self) -> String {
todo!()
}
}
#[derive(Debug)]
pub struct ApplicationInterpret {
pub features: Vec<Box<dyn ApplicationFeature>>,
}
#[async_trait]
impl<T: Topology> Interpret<T> for ApplicationInterpret {
async fn execute(&self, _inventory: &Inventory, _topology: &T) -> Result<Outcome, InterpretError> {
todo!()
}
fn get_name(&self) -> InterpretName {
todo!()
}
fn get_version(&self) -> Version {
todo!()
}
fn get_status(&self) -> InterpretStatus {
todo!()
}
fn get_children(&self) -> Vec<Id> {
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<bool, String>;
async fn uninstall(&self) -> Result<(), String>;
}
#[derive(Debug)]
pub struct BackupFeature;
#[async_trait]
impl ApplicationFeature for BackupFeature {
async fn ensure_installed(&self) -> Result<(), String> {
letian marked this conversation as resolved Outdated

naming could be revisited, but good enough for now

naming could be revisited, but good enough for now
todo!()
}
letian marked this conversation as resolved Outdated

is_installed and uninstall seem unnecessary for now

`is_installed` and `uninstall` seem unnecessary for now
async fn is_installed(&self) -> Result<bool, String> {
todo!()
}
async fn uninstall(&self) -> Result<(), String> {
todo!()
}
}

View File

@ -14,3 +14,4 @@ pub mod okd;
pub mod opnsense;
pub mod tenant;
pub mod tftp;
pub mod application;