refactor dyn KvTree out of services

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-28 22:51:39 +00:00
parent 57acc4f655
commit cb48e25783
69 changed files with 594 additions and 647 deletions

View file

@ -1,25 +1,26 @@
use std::{collections::HashMap, sync::Arc};
use conduit::{utils, warn, Error, Result};
use database::{Database, Map};
use ruma::{
api::client::error::ErrorKind,
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw,
RoomId, UserId,
};
use tracing::warn;
use crate::{services, utils, Error, KeyValueDatabase, KvTree, Result};
use crate::services;
pub(super) struct Data {
roomuserdataid_accountdata: Arc<dyn KvTree>,
roomusertype_roomuserdataid: Arc<dyn KvTree>,
roomuserdataid_accountdata: Arc<Map>,
roomusertype_roomuserdataid: Arc<Map>,
}
impl Data {
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
pub(super) fn new(db: &Arc<Database>) -> Self {
Self {
roomuserdataid_accountdata: db.roomuserdataid_accountdata.clone(),
roomusertype_roomuserdataid: db.roomusertype_roomuserdataid.clone(),
roomuserdataid_accountdata: db["roomuserdataid_accountdata"].clone(),
roomusertype_roomuserdataid: db["roomusertype_roomuserdataid"].clone(),
}
}

View file

@ -4,7 +4,7 @@ use std::{collections::HashMap, sync::Arc};
use conduit::{Result, Server};
use data::Data;
use database::KeyValueDatabase;
use database::Database;
use ruma::{
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw,
@ -16,7 +16,7 @@ pub struct Service {
}
impl Service {
pub fn build(_server: &Arc<Server>, db: &Arc<KeyValueDatabase>) -> Result<Self> {
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
Ok(Self {
db: Data::new(db),
})