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,18 +1,17 @@
use std::{mem::size_of, sync::Arc};
use database::KvTree;
use crate::{utils, KeyValueDatabase, Result};
use conduit::{utils, Result};
use database::{Database, Map};
pub(super) struct Data {
shorteventid_authchain: Arc<dyn KvTree>,
db: Arc<KeyValueDatabase>,
shorteventid_authchain: Arc<Map>,
db: Arc<Database>,
}
impl Data {
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
pub(super) fn new(db: &Arc<Database>) -> Self {
Self {
shorteventid_authchain: db.shorteventid_authchain.clone(),
shorteventid_authchain: db["shorteventid_authchain"].clone(),
db: db.clone(),
}
}

View file

@ -1,24 +1,23 @@
use conduit::Server;
use database::KeyValueDatabase;
mod data;
use std::{
collections::{BTreeSet, HashSet},
sync::Arc,
};
use conduit::{debug, error, trace, warn, Error, Result, Server};
use data::Data;
use database::Database;
use ruma::{api::client::error::ErrorKind, EventId, RoomId};
use tracing::{debug, error, trace, warn};
use crate::{services, Error, Result};
use crate::services;
pub struct Service {
db: Data,
}
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),
})