feat: Application module architecture and placeholder features #70
							
								
								
									
										83
									
								
								harmony/src/modules/application/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								harmony/src/modules/application/mod.rs
									
									
									
									
									
										Normal 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> { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     async fn is_installed(&self) -> Result<bool, String> { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     async fn uninstall(&self) -> Result<(), String> { | ||||
|         todo!() | ||||
|     } | ||||
| } | ||||
| @ -14,3 +14,4 @@ pub mod okd; | ||||
| pub mod opnsense; | ||||
| pub mod tenant; | ||||
| pub mod tftp; | ||||
| pub mod application; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user