use magnetar_calckey_model::{CalckeyCache, CalckeyModel}; use magnetar_common::config::MagnetarConfig; use thiserror::Error; pub mod user_cache; pub struct MagnetarService { pub db: CalckeyModel, pub cache: CalckeyCache, pub config: &'static MagnetarConfig, pub auth_cache: user_cache::UserCacheService, } #[derive(Debug, Error)] pub enum ServiceInitError { #[error("Authentication cache initialization error: {0}")] AuthCacheError(#[from] user_cache::UserCacheError), } impl MagnetarService { pub async fn new( config: &'static MagnetarConfig, db: CalckeyModel, cache: CalckeyCache, ) -> Result { let auth_cache = user_cache::UserCacheService::new(config, db.clone(), cache.clone()).await?; Ok(Self { db, cache, config, auth_cache, }) } }