codex_memory/application/
mod.rs1use anyhow::Result;
2use std::sync::Arc;
3
4pub mod application_service;
5pub mod command_handlers;
6pub mod dependency_container;
7pub mod lifecycle;
8
9pub use application_service::ApplicationService;
10pub use command_handlers::{
11 BackupCommandHandler, DatabaseCommandHandler, HealthCommandHandler, ManagerCommandHandler,
12 McpCommandHandler, ModelCommandHandler, ServerCommandHandler, SetupCommandHandler,
13};
14pub use dependency_container::DependencyContainer;
15pub use lifecycle::ApplicationLifecycle;
16
17pub struct Application {
19 pub container: Arc<DependencyContainer>,
20 pub service: Arc<ApplicationService>,
21 pub lifecycle: Arc<ApplicationLifecycle>,
22}
23
24impl Application {
25 pub async fn new() -> Result<Self> {
26 let container = Arc::new(DependencyContainer::new().await?);
27 let service = Arc::new(ApplicationService::new(container.clone()));
28 let lifecycle = Arc::new(ApplicationLifecycle::new(container.clone()));
29
30 Ok(Self {
31 container,
32 service,
33 lifecycle,
34 })
35 }
36
37 pub async fn initialize(&self) -> Result<()> {
38 self.lifecycle.initialize().await
39 }
40
41 pub async fn shutdown(&self) -> Result<()> {
42 self.lifecycle.shutdown().await
43 }
44}