39 lines
1.0 KiB
Rust
39 lines
1.0 KiB
Rust
use std::sync::Arc;
|
|
|
|
use como_core::{items::DynItemService, projects::DynProjectService, users::DynUserService};
|
|
use tracing::log::info;
|
|
|
|
use crate::{
|
|
configs::AppConfig,
|
|
database::ConnectionPool,
|
|
services::{
|
|
item_service::MemoryItemService, project_service::MemoryProjectService,
|
|
user_service::DefaultUserService,
|
|
},
|
|
};
|
|
|
|
#[derive(Clone)]
|
|
pub struct ServiceRegister {
|
|
pub item_service: DynItemService,
|
|
pub project_service: DynProjectService,
|
|
pub user_service: DynUserService,
|
|
}
|
|
|
|
impl ServiceRegister {
|
|
pub fn new(pool: ConnectionPool, _config: Arc<AppConfig>) -> Self {
|
|
info!("creating services");
|
|
|
|
let item_service = Arc::new(MemoryItemService::new()) as DynItemService;
|
|
let project_service = Arc::new(MemoryProjectService::new()) as DynProjectService;
|
|
let user_service = Arc::new(DefaultUserService::new(pool)) as DynUserService;
|
|
|
|
info!("services created succesfully");
|
|
|
|
Self {
|
|
item_service,
|
|
user_service,
|
|
project_service,
|
|
}
|
|
}
|
|
}
|