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,26 +1,28 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{ServerName, UserId};
|
||||
|
||||
use super::{Destination, SendingEvent};
|
||||
use crate::{services, utils, Error, KeyValueDatabase, KvTree, Result};
|
||||
use crate::services;
|
||||
|
||||
type OutgoingSendingIter<'a> = Box<dyn Iterator<Item = Result<(Vec<u8>, Destination, SendingEvent)>> + 'a>;
|
||||
type SendingEventIter<'a> = Box<dyn Iterator<Item = Result<(Vec<u8>, SendingEvent)>> + 'a>;
|
||||
|
||||
pub struct Data {
|
||||
servercurrentevent_data: Arc<dyn KvTree>,
|
||||
servernameevent_data: Arc<dyn KvTree>,
|
||||
servername_educount: Arc<dyn KvTree>,
|
||||
_db: Arc<KeyValueDatabase>,
|
||||
servercurrentevent_data: Arc<Map>,
|
||||
servernameevent_data: Arc<Map>,
|
||||
servername_educount: Arc<Map>,
|
||||
_db: Arc<Database>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: Arc<Database>) -> Self {
|
||||
Self {
|
||||
servercurrentevent_data: db.servercurrentevent_data.clone(),
|
||||
servernameevent_data: db.servernameevent_data.clone(),
|
||||
servername_educount: db.servername_educount.clone(),
|
||||
servercurrentevent_data: db["servercurrentevent_data"].clone(),
|
||||
servernameevent_data: db["servernameevent_data"].clone(),
|
||||
servername_educount: db["servername_educount"].clone(),
|
||||
_db: db,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use conduit::Server;
|
||||
|
||||
mod appservice;
|
||||
mod data;
|
||||
pub mod resolve;
|
||||
|
@ -8,7 +6,9 @@ mod sender;
|
|||
|
||||
use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
use conduit::{Error, Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
pub use resolve::FedDest;
|
||||
use ruma::{
|
||||
api::{appservice::Registration, OutgoingRequest},
|
||||
|
@ -17,7 +17,7 @@ use ruma::{
|
|||
use tokio::{sync::Mutex, task::JoinHandle};
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{server_is_ours, services, Error, KeyValueDatabase, Result};
|
||||
use crate::{server_is_ours, services};
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
|
@ -53,7 +53,7 @@ pub enum SendingEvent {
|
|||
}
|
||||
|
||||
impl Service {
|
||||
pub fn build(server: &Arc<Server>, db: &Arc<KeyValueDatabase>) -> Result<Arc<Self>> {
|
||||
pub fn build(server: &Arc<Server>, db: &Arc<Database>) -> Result<Arc<Self>> {
|
||||
let config = &server.config;
|
||||
let (sender, receiver) = loole::unbounded();
|
||||
Ok(Arc::new(Self {
|
||||
|
|
|
@ -23,7 +23,7 @@ use ruma::{
|
|||
use tracing::{debug, error, warn};
|
||||
|
||||
use super::{appservice, send, Destination, Msg, SendingEvent, Service};
|
||||
use crate::{service::presence::Presence, services, user_is_local, utils::calculate_hash, Error, PduEvent, Result};
|
||||
use crate::{presence::Presence, services, user_is_local, utils::calculate_hash, Error, PduEvent, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
enum TransactionStatus {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue