refactor dyn KvTree out of services
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
57acc4f655
commit
cb48e25783
69 changed files with 594 additions and 647 deletions
|
@ -1,23 +1,22 @@
|
|||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use conduit::utils::mutex_map;
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{EventId, OwnedEventId, RoomId};
|
||||
use utils::mutex_map;
|
||||
|
||||
use crate::{utils, Error, KeyValueDatabase, Result};
|
||||
|
||||
pub struct Data {
|
||||
shorteventid_shortstatehash: Arc<dyn KvTree>,
|
||||
roomid_pduleaves: Arc<dyn KvTree>,
|
||||
roomid_shortstatehash: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
shorteventid_shortstatehash: Arc<Map>,
|
||||
roomid_pduleaves: Arc<Map>,
|
||||
roomid_shortstatehash: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
shorteventid_shortstatehash: db.shorteventid_shortstatehash.clone(),
|
||||
roomid_pduleaves: db.roomid_pduleaves.clone(),
|
||||
roomid_shortstatehash: db.roomid_shortstatehash.clone(),
|
||||
shorteventid_shortstatehash: db["shorteventid_shortstatehash"].clone(),
|
||||
roomid_pduleaves: db["roomid_pduleaves"].clone(),
|
||||
roomid_shortstatehash: db["roomid_shortstatehash"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use conduit::utils::mutex_map;
|
||||
use conduit::{
|
||||
utils::{calculate_hash, mutex_map},
|
||||
warn, Error, Result, Server,
|
||||
};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{
|
||||
api::client::error::ErrorKind,
|
||||
events::{
|
||||
|
@ -19,17 +21,16 @@ use ruma::{
|
|||
state_res::{self, StateMap},
|
||||
EventId, OwnedEventId, RoomId, RoomVersionId, UserId,
|
||||
};
|
||||
use tracing::warn;
|
||||
|
||||
use super::state_compressor::CompressedStateEvent;
|
||||
use crate::{services, utils::calculate_hash, Error, PduEvent, Result};
|
||||
use crate::{services, PduEvent};
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
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),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue