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,18 +1,17 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::api::appservice::Registration;
|
||||
|
||||
use crate::{utils, Error, KeyValueDatabase, Result};
|
||||
|
||||
pub struct Data {
|
||||
id_appserviceregistrations: Arc<dyn KvTree>,
|
||||
id_appserviceregistrations: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
id_appserviceregistrations: db.id_appserviceregistrations.clone(),
|
||||
id_appserviceregistrations: db["id_appserviceregistrations"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ mod data;
|
|||
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
pub use data::Data;
|
||||
use conduit::{Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use futures_util::Future;
|
||||
use regex::RegexSet;
|
||||
use ruma::{
|
||||
|
@ -11,7 +13,7 @@ use ruma::{
|
|||
};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{services, Result};
|
||||
use crate::services;
|
||||
|
||||
/// Compiled regular expressions for a namespace
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -117,11 +119,8 @@ pub struct Service {
|
|||
registration_info: RwLock<BTreeMap<String, RegistrationInfo>>,
|
||||
}
|
||||
|
||||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
impl Service {
|
||||
pub fn build(_server: &Arc<Server>, db: &Arc<KeyValueDatabase>) -> Result<Self> {
|
||||
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
|
||||
let mut registration_info = BTreeMap::new();
|
||||
let db = Data::new(db);
|
||||
// Inserting registrations into cache
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue