use broker::manager::MqttBroker; use config::load_config; use server::Server; use std::sync::Arc; use storage::{StorageRepositoryImpl, StorageStrategy}; pub mod bridge; pub mod broker; pub mod config; pub mod server; pub mod storage; #[tokio::main] async fn main() -> anyhow::Result<()> { let cfg = load_config()?; let storage = Arc::new(if cfg.storage.sqlite { StorageRepositoryImpl::new(StorageStrategy::SQLite(format!( "{}agents.db", cfg.storage.db_path ))) } else { StorageRepositoryImpl::new(StorageStrategy::InMemory) }); let broker = MqttBroker::new(cfg.mqtt, Arc::clone(&storage)).await; let server = Server::new(broker.clients(), Arc::clone(&storage)); tokio::select! { res = broker.run() => res?, res = server.serve() => res, } Ok(()) }