Services refactor
Replace structs of Dep<Service> with OnceServices, so each service has a Services reference Remove service name => Service map Flatten Services.rooms Make reqwest Clients lazy initialized (client service)
This commit is contained in:
@@ -4,11 +4,11 @@ use ruma::{RoomId, UserId};
|
||||
use tuwunel_core::{Result, implement};
|
||||
use tuwunel_database::{Database, Deserialized, Map};
|
||||
|
||||
use crate::{Dep, globals, rooms, rooms::short::ShortStateHash};
|
||||
use crate::rooms::short::ShortStateHash;
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
services: Services,
|
||||
services: Arc<crate::services::OnceServices>,
|
||||
}
|
||||
|
||||
struct Data {
|
||||
@@ -19,11 +19,6 @@ struct Data {
|
||||
roomsynctoken_shortstatehash: Arc<Map>,
|
||||
}
|
||||
|
||||
struct Services {
|
||||
globals: Dep<globals::Service>,
|
||||
short: Dep<rooms::short::Service>,
|
||||
}
|
||||
|
||||
impl crate::Service for Service {
|
||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
Ok(Arc::new(Self {
|
||||
@@ -34,11 +29,7 @@ impl crate::Service for Service {
|
||||
roomuserid_lastnotificationread: args.db["userroomid_highlightcount"].clone(),
|
||||
roomsynctoken_shortstatehash: args.db["roomsynctoken_shortstatehash"].clone(),
|
||||
},
|
||||
|
||||
services: Services {
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
short: args.depend::<rooms::short::Service>("rooms::short"),
|
||||
},
|
||||
services: args.services.clone(),
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user