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,25 +1,25 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{error, utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{OwnedRoomId, RoomId};
|
||||
use tracing::error;
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, Result};
|
||||
use crate::services;
|
||||
|
||||
pub struct Data {
|
||||
disabledroomids: Arc<dyn KvTree>,
|
||||
bannedroomids: Arc<dyn KvTree>,
|
||||
roomid_shortroomid: Arc<dyn KvTree>,
|
||||
pduid_pdu: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
disabledroomids: Arc<Map>,
|
||||
bannedroomids: Arc<Map>,
|
||||
roomid_shortroomid: Arc<Map>,
|
||||
pduid_pdu: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
disabledroomids: db.disabledroomids.clone(),
|
||||
bannedroomids: db.bannedroomids.clone(),
|
||||
roomid_shortroomid: db.roomid_shortroomid.clone(),
|
||||
pduid_pdu: db.pduid_pdu.clone(),
|
||||
disabledroomids: db["disabledroomids"].clone(),
|
||||
bannedroomids: db["bannedroomids"].clone(),
|
||||
roomid_shortroomid: db["roomid_shortroomid"].clone(),
|
||||
pduid_pdu: db["pduid_pdu"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::{Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{OwnedRoomId, RoomId};
|
||||
|
||||
use crate::Result;
|
||||
|
||||
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