codex_memory/application/
application_service.rs1use crate::application::DependencyContainer;
2use anyhow::Result;
3use std::sync::Arc;
4use tracing::info;
5
6pub struct ApplicationService {
9 container: Arc<DependencyContainer>,
10}
11
12impl ApplicationService {
13 pub fn new(container: Arc<DependencyContainer>) -> Self {
14 Self { container }
15 }
16
17 pub async fn get_health_status(&self) -> Result<bool> {
19 self.container.health_check().await
20 }
21
22 pub fn get_config_summary(&self) -> ConfigSummary {
24 ConfigSummary {
25 database_url: self.container.config.safe_database_url(),
26 embedding_provider: self.container.config.embedding.provider.clone(),
27 embedding_model: self.container.config.embedding.model.clone(),
28 http_port: self.container.config.http_port,
29 mcp_port: self.container.config.mcp_port,
30 tier_manager_enabled: self.container.config.tier_manager.enabled,
31 backup_enabled: self.container.config.backup.enabled,
32 }
33 }
34
35 pub async fn initialize_services(&self) -> Result<()> {
37 info!("🔧 Initializing application services...");
38
39 if let Some(ref tier_manager) = self.container.tier_manager {
41 tier_manager.start().await?;
42 info!("✅ Tier management service started");
43 }
44
45 if let Some(ref backup_manager) = self.container.backup_manager {
47 backup_manager.initialize().await?;
48 info!("✅ Backup service initialized");
49 }
50
51 if let Some(ref _harvester) = self.container.harvester_service {
53 info!("✅ Silent harvester service started (placeholder)");
56 }
57
58 info!("🎉 All application services initialized successfully");
59 Ok(())
60 }
61
62 pub async fn shutdown_services(&self) -> Result<()> {
64 info!("🛑 Shutting down application services...");
65
66 if let Some(ref _harvester) = self.container.harvester_service {
68 info!("✅ Silent harvester service stopped (placeholder)");
71 }
72
73 if let Some(ref tier_manager) = self.container.tier_manager {
74 tier_manager.stop().await;
75 info!("✅ Tier management service stopped");
76 }
77
78 info!("🎉 All application services shutdown gracefully");
79 Ok(())
80 }
81}
82
83#[derive(Debug, Clone)]
84pub struct ConfigSummary {
85 pub database_url: String,
86 pub embedding_provider: String,
87 pub embedding_model: String,
88 pub http_port: u16,
89 pub mcp_port: Option<u16>,
90 pub tier_manager_enabled: bool,
91 pub backup_enabled: bool,
92}