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,22 +1,23 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{api::client::error::ErrorKind, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomAliasId, RoomId, UserId};
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, Result};
|
||||
use crate::services;
|
||||
|
||||
pub struct Data {
|
||||
alias_userid: Arc<dyn KvTree>,
|
||||
alias_roomid: Arc<dyn KvTree>,
|
||||
aliasid_alias: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
alias_userid: Arc<Map>,
|
||||
alias_roomid: Arc<Map>,
|
||||
aliasid_alias: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
alias_userid: db.alias_userid.clone(),
|
||||
alias_roomid: db.alias_roomid.clone(),
|
||||
aliasid_alias: db.aliasid_alias.clone(),
|
||||
alias_userid: db["alias_userid"].clone(),
|
||||
alias_roomid: db["alias_roomid"].clone(),
|
||||
aliasid_alias: db["aliasid_alias"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +56,7 @@ impl Data {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn resolve_local_alias(&self, alias: &RoomAliasId) -> Result<Option<OwnedRoomId>> {
|
||||
pub(super) fn resolve_local_alias(&self, alias: &RoomAliasId) -> Result<Option<OwnedRoomId>> {
|
||||
self.alias_roomid
|
||||
.get(alias.alias().as_bytes())?
|
||||
.map(|bytes| {
|
||||
|
@ -81,7 +82,7 @@ impl Data {
|
|||
.transpose()
|
||||
}
|
||||
|
||||
pub fn local_aliases_for_room<'a>(
|
||||
pub(super) fn local_aliases_for_room<'a>(
|
||||
&'a self, room_id: &RoomId,
|
||||
) -> Box<dyn Iterator<Item = Result<OwnedRoomAliasId>> + 'a> {
|
||||
let mut prefix = room_id.as_bytes().to_vec();
|
||||
|
@ -95,7 +96,7 @@ impl Data {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn all_local_aliases<'a>(&'a self) -> Box<dyn Iterator<Item = Result<(OwnedRoomId, String)>> + 'a> {
|
||||
pub(super) fn all_local_aliases<'a>(&'a self) -> Box<dyn Iterator<Item = Result<(OwnedRoomId, String)>> + 'a> {
|
||||
Box::new(
|
||||
self.alias_roomid
|
||||
.iter()
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::{Error, Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{
|
||||
api::client::error::ErrorKind,
|
||||
events::{
|
||||
|
@ -15,14 +14,14 @@ use ruma::{
|
|||
OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result};
|
||||
use crate::services;
|
||||
|
||||
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),
|
||||
})
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{OwnedRoomId, RoomId};
|
||||
|
||||
use crate::{utils, Error, KeyValueDatabase, Result};
|
||||
|
||||
pub(super) struct Data {
|
||||
publicroomids: Arc<dyn KvTree>,
|
||||
publicroomids: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
publicroomids: db.publicroomids.clone(),
|
||||
publicroomids: db["publicroomids"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::Server;
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{OwnedRoomId, RoomId};
|
||||
|
||||
use crate::Result;
|
||||
|
@ -15,7 +14,7 @@ pub struct Service {
|
|||
}
|
||||
|
||||
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),
|
||||
})
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod parse_incoming_pdu;
|
||||
mod signing_keys;
|
||||
|
||||
|
@ -12,6 +9,8 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use conduit::{debug_error, debug_info, Error, Result, Server};
|
||||
use database::Database;
|
||||
use futures_util::Future;
|
||||
pub use parse_incoming_pdu::parse_incoming_pdu;
|
||||
use ruma::{
|
||||
|
@ -32,7 +31,7 @@ use tokio::sync::RwLock;
|
|||
use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
use super::state_compressor::CompressedStateEvent;
|
||||
use crate::{debug_error, debug_info, pdu, services, Error, PduEvent, Result};
|
||||
use crate::{pdu, services, PduEvent};
|
||||
|
||||
pub struct Service;
|
||||
|
||||
|
@ -45,7 +44,7 @@ type AsyncRecursiveCanonicalJsonResult<'a> =
|
|||
AsyncRecursiveType<'a, Result<(Arc<PduEvent>, BTreeMap<String, CanonicalJsonValue>)>>;
|
||||
|
||||
impl Service {
|
||||
pub fn build(_server: &Arc<Server>, _db: &Arc<KeyValueDatabase>) -> Result<Self> { Ok(Self {}) }
|
||||
pub fn build(_server: &Arc<Server>, _db: &Arc<Database>) -> Result<Self> { Ok(Self {}) }
|
||||
|
||||
/// When receiving an event one needs to:
|
||||
/// 0. Check the server is in the room
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use conduit::{Error, Result};
|
||||
use ruma::{api::client::error::ErrorKind, CanonicalJsonObject, OwnedEventId, OwnedRoomId, RoomId};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{service::pdu::gen_event_id_canonical_json, services, Error, Result};
|
||||
use crate::{pdu::gen_event_id_canonical_json, services};
|
||||
|
||||
pub fn parse_incoming_pdu(pdu: &RawJsonValue) -> Result<(OwnedEventId, CanonicalJsonObject, OwnedRoomId)> {
|
||||
let value: CanonicalJsonObject = serde_json::from_str(pdu.get()).map_err(|e| {
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::Result;
|
||||
use database::{Database, Map};
|
||||
use ruma::{DeviceId, RoomId, UserId};
|
||||
|
||||
use crate::{KeyValueDatabase, Result};
|
||||
|
||||
pub struct Data {
|
||||
lazyloadedids: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
lazyloadedids: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
lazyloadedids: db.lazyloadedids.clone(),
|
||||
lazyloadedids: db["lazyloadedids"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use conduit::Server;
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{DeviceId, OwnedDeviceId, OwnedRoomId, OwnedUserId, RoomId, UserId};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::{PduCount, Result};
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
db: Data,
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub lazy_load_waiting: Mutex<HashMap<(OwnedUserId, OwnedDeviceId, OwnedRoomId, PduCount), HashSet<OwnedUserId>>>,
|
||||
}
|
||||
|
||||
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),
|
||||
lazy_load_waiting: Mutex::new(HashMap::new()),
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{CanonicalJsonObject, EventId};
|
||||
|
||||
use crate::{Error, KeyValueDatabase, PduEvent, Result};
|
||||
use crate::PduEvent;
|
||||
|
||||
pub struct Data {
|
||||
eventid_outlierpdu: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
eventid_outlierpdu: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
eventid_outlierpdu: db.eventid_outlierpdu.clone(),
|
||||
eventid_outlierpdu: db["eventid_outlierpdu"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::{Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{CanonicalJsonObject, EventId};
|
||||
|
||||
use crate::{PduEvent, Result};
|
||||
use crate::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),
|
||||
})
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
use std::{mem::size_of, sync::Arc};
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{EventId, RoomId, UserId};
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, PduCount, PduEvent, Result};
|
||||
use crate::{services, PduCount, PduEvent};
|
||||
|
||||
pub(super) struct Data {
|
||||
tofrom_relation: Arc<dyn KvTree>,
|
||||
referencedevents: Arc<dyn KvTree>,
|
||||
softfailedeventids: Arc<dyn KvTree>,
|
||||
tofrom_relation: Arc<Map>,
|
||||
referencedevents: Arc<Map>,
|
||||
softfailedeventids: Arc<Map>,
|
||||
}
|
||||
|
||||
type PdusIterItem = Result<(PduCount, PduEvent)>;
|
||||
type PdusIterator<'a> = Box<dyn Iterator<Item = PdusIterItem> + 'a>;
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
tofrom_relation: db.tofrom_relation.clone(),
|
||||
referencedevents: db.referencedevents.clone(),
|
||||
softfailedeventids: db.softfailedeventids.clone(),
|
||||
tofrom_relation: db["tofrom_relation"].clone(),
|
||||
referencedevents: db["referencedevents"].clone(),
|
||||
softfailedeventids: db["softfailedeventids"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::{Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{
|
||||
api::{client::relations::get_relating_events, Direction},
|
||||
events::{relation::RelationType, TimelineEventType},
|
||||
|
@ -13,7 +12,7 @@ use ruma::{
|
|||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{services, PduCount, PduEvent, Result};
|
||||
use crate::{services, PduCount, PduEvent};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
@ -30,7 +29,7 @@ struct ExtractRelatesToEventId {
|
|||
}
|
||||
|
||||
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),
|
||||
})
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
use std::{mem::size_of, sync::Arc};
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{
|
||||
events::{receipt::ReceiptEvent, AnySyncEphemeralRoomEvent},
|
||||
serde::Raw,
|
||||
CanonicalJsonObject, OwnedUserId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, Result};
|
||||
use crate::services;
|
||||
|
||||
type AnySyncEphemeralRoomEventIter<'a> =
|
||||
Box<dyn Iterator<Item = Result<(OwnedUserId, u64, Raw<AnySyncEphemeralRoomEvent>)>> + 'a>;
|
||||
|
||||
pub(super) struct Data {
|
||||
roomuserid_privateread: Arc<dyn KvTree>,
|
||||
roomuserid_lastprivatereadupdate: Arc<dyn KvTree>,
|
||||
readreceiptid_readreceipt: Arc<dyn KvTree>,
|
||||
roomuserid_privateread: Arc<Map>,
|
||||
roomuserid_lastprivatereadupdate: Arc<Map>,
|
||||
readreceiptid_readreceipt: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
roomuserid_privateread: db.roomuserid_privateread.clone(),
|
||||
roomuserid_lastprivatereadupdate: db.roomuserid_lastprivatereadupdate.clone(),
|
||||
readreceiptid_readreceipt: db.readreceiptid_readreceipt.clone(),
|
||||
roomuserid_privateread: db["roomuserid_privateread"].clone(),
|
||||
roomuserid_lastprivatereadupdate: db["roomuserid_lastprivatereadupdate"].clone(),
|
||||
readreceiptid_readreceipt: db["readreceiptid_readreceipt"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::{Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId};
|
||||
|
||||
use crate::{services, 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),
|
||||
})
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::RoomId;
|
||||
|
||||
use crate::{services, utils, KeyValueDatabase, Result};
|
||||
use crate::services;
|
||||
|
||||
type SearchPdusResult<'a> = Result<Option<(Box<dyn Iterator<Item = Vec<u8>> + 'a>, Vec<String>)>>;
|
||||
|
||||
pub struct Data {
|
||||
tokenids: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
tokenids: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
tokenids: db.tokenids.clone(),
|
||||
tokenids: db["tokenids"].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::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),
|
||||
})
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduit::warn;
|
||||
use database::{KeyValueDatabase, KvTree};
|
||||
use conduit::{utils, warn, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{events::StateEventType, EventId, RoomId};
|
||||
|
||||
use crate::{services, utils, Error, Result};
|
||||
use crate::services;
|
||||
|
||||
pub(super) struct Data {
|
||||
eventid_shorteventid: Arc<dyn KvTree>,
|
||||
shorteventid_eventid: Arc<dyn KvTree>,
|
||||
statekey_shortstatekey: Arc<dyn KvTree>,
|
||||
shortstatekey_statekey: Arc<dyn KvTree>,
|
||||
roomid_shortroomid: Arc<dyn KvTree>,
|
||||
statehash_shortstatehash: Arc<dyn KvTree>,
|
||||
eventid_shorteventid: Arc<Map>,
|
||||
shorteventid_eventid: Arc<Map>,
|
||||
statekey_shortstatekey: Arc<Map>,
|
||||
shortstatekey_statekey: Arc<Map>,
|
||||
roomid_shortroomid: Arc<Map>,
|
||||
statehash_shortstatehash: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
eventid_shorteventid: db.eventid_shorteventid.clone(),
|
||||
shorteventid_eventid: db.shorteventid_eventid.clone(),
|
||||
statekey_shortstatekey: db.statekey_shortstatekey.clone(),
|
||||
shortstatekey_statekey: db.shortstatekey_statekey.clone(),
|
||||
roomid_shortroomid: db.roomid_shortroomid.clone(),
|
||||
statehash_shortstatehash: db.statehash_shortstatehash.clone(),
|
||||
eventid_shorteventid: db["eventid_shorteventid"].clone(),
|
||||
shorteventid_eventid: db["shorteventid_eventid"].clone(),
|
||||
statekey_shortstatekey: db["statekey_shortstatekey"].clone(),
|
||||
shortstatekey_statekey: db["shortstatekey_statekey"].clone(),
|
||||
roomid_shortroomid: db["roomid_shortroomid"].clone(),
|
||||
statehash_shortstatehash: db["statehash_shortstatehash"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +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::{events::StateEventType, EventId, RoomId};
|
||||
|
||||
use crate::Result;
|
||||
|
||||
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),
|
||||
})
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
use conduit::{debug_info, Error, Result, Server};
|
||||
use database::Database;
|
||||
use lru_cache::LruCache;
|
||||
use ruma::{
|
||||
api::{
|
||||
|
@ -31,7 +31,7 @@ use ruma::{
|
|||
use tokio::sync::Mutex;
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use crate::{debug_info, server_is_ours, services, Error, Result};
|
||||
use crate::{server_is_ours, services};
|
||||
|
||||
pub struct CachedSpaceHierarchySummary {
|
||||
summary: SpaceHierarchyParentSummary,
|
||||
|
@ -333,7 +333,7 @@ impl From<CachedSpaceHierarchySummary> for SpaceHierarchyRoomsChunk {
|
|||
}
|
||||
|
||||
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 config = &server.config;
|
||||
Ok(Self {
|
||||
roomid_spacehierarchy_cache: Mutex::new(LruCache::new(
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{events::StateEventType, EventId, RoomId};
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, PduEvent, Result};
|
||||
use crate::{services, PduEvent};
|
||||
|
||||
pub struct Data {
|
||||
eventid_shorteventid: Arc<dyn KvTree>,
|
||||
shorteventid_shortstatehash: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
eventid_shorteventid: Arc<Map>,
|
||||
shorteventid_shortstatehash: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
eventid_shorteventid: db.eventid_shorteventid.clone(),
|
||||
shorteventid_shortstatehash: db.shorteventid_shortstatehash.clone(),
|
||||
eventid_shorteventid: db["eventid_shorteventid"].clone(),
|
||||
shorteventid_shortstatehash: db["shorteventid_shortstatehash"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
use std::sync::Mutex as StdMutex;
|
||||
|
||||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{Arc, Mutex},
|
||||
sync::{Arc, Mutex as StdMutex, Mutex},
|
||||
};
|
||||
|
||||
use conduit::utils::mutex_map;
|
||||
use conduit::{error, utils::mutex_map, warn, Error, Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use lru_cache::LruCache;
|
||||
use ruma::{
|
||||
events::{
|
||||
|
@ -29,18 +26,17 @@ use ruma::{
|
|||
EventId, OwnedRoomAliasId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{service::pdu::PduBuilder, services, Error, PduEvent, Result};
|
||||
use crate::{pdu::PduBuilder, services, PduEvent};
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
db: Data,
|
||||
pub server_visibility_cache: Mutex<LruCache<(OwnedServerName, u64), bool>>,
|
||||
pub user_visibility_cache: Mutex<LruCache<(OwnedUserId, u64), bool>>,
|
||||
}
|
||||
|
||||
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 config = &server.config;
|
||||
Ok(Self {
|
||||
db: Data::new(db),
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use std::collections::HashSet;
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use itertools::Itertools;
|
||||
use ruma::{
|
||||
events::{AnyStrippedStateEvent, AnySyncStateEvent},
|
||||
|
@ -7,51 +9,42 @@ use ruma::{
|
|||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
appservice::RegistrationInfo,
|
||||
services, user_is_local,
|
||||
utils::{self},
|
||||
Error, KeyValueDatabase, Result,
|
||||
};
|
||||
use crate::{appservice::RegistrationInfo, services, user_is_local};
|
||||
|
||||
type StrippedStateEventIter<'a> = Box<dyn Iterator<Item = Result<(OwnedRoomId, Vec<Raw<AnyStrippedStateEvent>>)>> + 'a>;
|
||||
type AnySyncStateEventIter<'a> = Box<dyn Iterator<Item = Result<(OwnedRoomId, Vec<Raw<AnySyncStateEvent>>)>> + 'a>;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
|
||||
pub struct Data {
|
||||
userroomid_joined: Arc<dyn KvTree>,
|
||||
roomuserid_joined: Arc<dyn KvTree>,
|
||||
userroomid_invitestate: Arc<dyn KvTree>,
|
||||
roomuserid_invitecount: Arc<dyn KvTree>,
|
||||
userroomid_leftstate: Arc<dyn KvTree>,
|
||||
roomuserid_leftcount: Arc<dyn KvTree>,
|
||||
roomid_inviteviaservers: Arc<dyn KvTree>,
|
||||
roomuseroncejoinedids: Arc<dyn KvTree>,
|
||||
roomid_joinedcount: Arc<dyn KvTree>,
|
||||
roomid_invitedcount: Arc<dyn KvTree>,
|
||||
roomserverids: Arc<dyn KvTree>,
|
||||
serverroomids: Arc<dyn KvTree>,
|
||||
db: Arc<KeyValueDatabase>,
|
||||
pub(super) struct Data {
|
||||
userroomid_joined: Arc<Map>,
|
||||
roomuserid_joined: Arc<Map>,
|
||||
userroomid_invitestate: Arc<Map>,
|
||||
roomuserid_invitecount: Arc<Map>,
|
||||
userroomid_leftstate: Arc<Map>,
|
||||
roomuserid_leftcount: Arc<Map>,
|
||||
roomid_inviteviaservers: Arc<Map>,
|
||||
roomuseroncejoinedids: Arc<Map>,
|
||||
roomid_joinedcount: Arc<Map>,
|
||||
roomid_invitedcount: Arc<Map>,
|
||||
roomserverids: Arc<Map>,
|
||||
serverroomids: Arc<Map>,
|
||||
db: Arc<Database>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
userroomid_joined: db.userroomid_joined.clone(),
|
||||
roomuserid_joined: db.roomuserid_joined.clone(),
|
||||
userroomid_invitestate: db.userroomid_invitestate.clone(),
|
||||
roomuserid_invitecount: db.roomuserid_invitecount.clone(),
|
||||
userroomid_leftstate: db.userroomid_leftstate.clone(),
|
||||
roomuserid_leftcount: db.roomuserid_leftcount.clone(),
|
||||
roomid_inviteviaservers: db.roomid_inviteviaservers.clone(),
|
||||
roomuseroncejoinedids: db.roomuseroncejoinedids.clone(),
|
||||
roomid_joinedcount: db.roomid_joinedcount.clone(),
|
||||
roomid_invitedcount: db.roomid_invitedcount.clone(),
|
||||
roomserverids: db.roomserverids.clone(),
|
||||
serverroomids: db.serverroomids.clone(),
|
||||
userroomid_joined: db["userroomid_joined"].clone(),
|
||||
roomuserid_joined: db["roomuserid_joined"].clone(),
|
||||
userroomid_invitestate: db["userroomid_invitestate"].clone(),
|
||||
roomuserid_invitecount: db["roomuserid_invitecount"].clone(),
|
||||
userroomid_leftstate: db["userroomid_leftstate"].clone(),
|
||||
roomuserid_leftcount: db["roomuserid_leftcount"].clone(),
|
||||
roomid_inviteviaservers: db["roomid_inviteviaservers"].clone(),
|
||||
roomuseroncejoinedids: db["roomuseroncejoinedids"].clone(),
|
||||
roomid_joinedcount: db["roomid_joinedcount"].clone(),
|
||||
roomid_invitedcount: db["roomid_invitedcount"].clone(),
|
||||
roomserverids: db["roomserverids"].clone(),
|
||||
serverroomids: db["serverroomids"].clone(),
|
||||
db: db.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
mod data;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduit::Server;
|
||||
use conduit::{error, warn, Error, Result, Server};
|
||||
use data::Data;
|
||||
use database::KeyValueDatabase;
|
||||
use database::Database;
|
||||
use itertools::Itertools;
|
||||
use ruma::{
|
||||
events::{
|
||||
|
@ -19,18 +21,15 @@ use ruma::{
|
|||
serde::Raw,
|
||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||
};
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{service::appservice::RegistrationInfo, services, user_is_local, Error, Result};
|
||||
|
||||
mod data;
|
||||
use crate::{appservice::RegistrationInfo, services, user_is_local};
|
||||
|
||||
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),
|
||||
})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::{collections::HashSet, mem::size_of, sync::Arc};
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
|
||||
use super::CompressedStateEvent;
|
||||
use crate::{utils, Error, KeyValueDatabase, Result};
|
||||
|
||||
pub(super) struct StateDiff {
|
||||
pub(super) parent: Option<u64>,
|
||||
|
@ -11,14 +11,14 @@ pub(super) struct StateDiff {
|
|||
pub(super) removed: Arc<HashSet<CompressedStateEvent>>,
|
||||
}
|
||||
|
||||
pub struct Data {
|
||||
shortstatehash_statediff: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
shortstatehash_statediff: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
shortstatehash_statediff: db.shortstatehash_statediff.clone(),
|
||||
shortstatehash_statediff: db["shortstatehash_statediff"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
use std::sync::Mutex as StdMutex;
|
||||
|
||||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
mem::size_of,
|
||||
sync::{Arc, Mutex},
|
||||
sync::{Arc, Mutex as StdMutex, Mutex},
|
||||
};
|
||||
|
||||
use conduit::{utils, Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use lru_cache::LruCache;
|
||||
use ruma::{EventId, RoomId};
|
||||
|
||||
use self::data::StateDiff;
|
||||
use crate::{services, utils, Result};
|
||||
use crate::services;
|
||||
|
||||
type StateInfoLruCache = Mutex<
|
||||
LruCache<
|
||||
|
@ -49,13 +47,13 @@ type HashSetCompressStateEvent = Result<(u64, Arc<HashSet<CompressedStateEvent>>
|
|||
pub type CompressedStateEvent = [u8; 2 * size_of::<u64>()];
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
db: Data,
|
||||
|
||||
pub stateinfo_cache: StateInfoLruCache,
|
||||
}
|
||||
|
||||
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 config = &server.config;
|
||||
Ok(Self {
|
||||
db: Data::new(db),
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
use std::{mem::size_of, sync::Arc};
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{api::client::threads::get_threads::v1::IncludeThreads, OwnedUserId, RoomId, UserId};
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, PduEvent, Result};
|
||||
use crate::{services, PduEvent};
|
||||
|
||||
type PduEventIterResult<'a> = Result<Box<dyn Iterator<Item = Result<(u64, PduEvent)>> + 'a>>;
|
||||
|
||||
pub struct Data {
|
||||
threadid_userids: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
threadid_userids: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
threadid_userids: db.threadid_userids.clone(),
|
||||
threadid_userids: db["threadid_userids"].clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduit::{Error, Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, threads::get_threads::v1::IncludeThreads},
|
||||
events::relation::BundledThread,
|
||||
|
@ -13,14 +12,14 @@ use ruma::{
|
|||
};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{services, 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),
|
||||
})
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
use std::{collections::hash_map, mem::size_of, sync::Arc};
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{error, utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{api::client::error::ErrorKind, CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId};
|
||||
use tracing::error;
|
||||
|
||||
use super::PduCount;
|
||||
use crate::{services, utils, Error, KeyValueDatabase, PduEvent, Result};
|
||||
use crate::{services, PduCount, PduEvent};
|
||||
|
||||
pub struct Data {
|
||||
eventid_pduid: Arc<dyn KvTree>,
|
||||
pduid_pdu: Arc<dyn KvTree>,
|
||||
eventid_outlierpdu: Arc<dyn KvTree>,
|
||||
userroomid_notificationcount: Arc<dyn KvTree>,
|
||||
userroomid_highlightcount: Arc<dyn KvTree>,
|
||||
db: Arc<KeyValueDatabase>,
|
||||
pub(super) struct Data {
|
||||
eventid_pduid: Arc<Map>,
|
||||
pduid_pdu: Arc<Map>,
|
||||
eventid_outlierpdu: Arc<Map>,
|
||||
userroomid_notificationcount: Arc<Map>,
|
||||
userroomid_highlightcount: Arc<Map>,
|
||||
db: Arc<Database>,
|
||||
}
|
||||
|
||||
type PdusIterItem = Result<(PduCount, PduEvent)>;
|
||||
type PdusIterator<'a> = Box<dyn Iterator<Item = PdusIterItem> + 'a>;
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
eventid_pduid: db.eventid_pduid.clone(),
|
||||
pduid_pdu: db.pduid_pdu.clone(),
|
||||
eventid_outlierpdu: db.eventid_outlierpdu.clone(),
|
||||
userroomid_notificationcount: db.userroomid_notificationcount.clone(),
|
||||
userroomid_highlightcount: db.userroomid_highlightcount.clone(),
|
||||
eventid_pduid: db["eventid_pduid"].clone(),
|
||||
pduid_pdu: db["pduid_pdu"].clone(),
|
||||
eventid_outlierpdu: db["eventid_outlierpdu"].clone(),
|
||||
userroomid_notificationcount: db["userroomid_notificationcount"].clone(),
|
||||
userroomid_highlightcount: db["userroomid_highlightcount"].clone(),
|
||||
db: db.clone(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
|
||||
mod data;
|
||||
|
||||
use std::{
|
||||
|
@ -8,7 +5,9 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use conduit::{debug, error, info, utils, utils::mutex_map, warn, Error, Result, Server};
|
||||
use data::Data;
|
||||
use database::Database;
|
||||
use itertools::Itertools;
|
||||
use rand::prelude::SliceRandom;
|
||||
use ruma::{
|
||||
|
@ -34,24 +33,13 @@ use ruma::{
|
|||
use serde::Deserialize;
|
||||
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
use tracing::{debug, error, info, warn};
|
||||
|
||||
use super::state_compressor::CompressedStateEvent;
|
||||
use crate::{
|
||||
admin,
|
||||
server_is_ours,
|
||||
//api::server_server,
|
||||
service::{
|
||||
appservice::NamespaceRegex,
|
||||
pdu::{EventHash, PduBuilder},
|
||||
rooms::event_handler::parse_incoming_pdu,
|
||||
},
|
||||
services,
|
||||
utils::{self, mutex_map},
|
||||
Error,
|
||||
PduCount,
|
||||
PduEvent,
|
||||
Result,
|
||||
appservice::NamespaceRegex,
|
||||
pdu::{EventHash, PduBuilder},
|
||||
rooms::{event_handler::parse_incoming_pdu, state_compressor::CompressedStateEvent},
|
||||
server_is_ours, services, PduCount, PduEvent,
|
||||
};
|
||||
|
||||
// Update Relationships
|
||||
|
@ -77,13 +65,13 @@ struct ExtractBody {
|
|||
}
|
||||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
db: Data,
|
||||
|
||||
pub lasttimelinecount_cache: Mutex<HashMap<OwnedRoomId, PduCount>>,
|
||||
}
|
||||
|
||||
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),
|
||||
lasttimelinecount_cache: Mutex::new(HashMap::new()),
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduit::Server;
|
||||
use database::KeyValueDatabase;
|
||||
use conduit::{debug_info, trace, utils, Result, Server};
|
||||
use database::Database;
|
||||
use ruma::{
|
||||
api::federation::transactions::edu::{Edu, TypingContent},
|
||||
events::SyncEphemeralRoomEvent,
|
||||
OwnedRoomId, OwnedUserId, RoomId, UserId,
|
||||
};
|
||||
use tokio::sync::{broadcast, RwLock};
|
||||
use tracing::trace;
|
||||
|
||||
use crate::{
|
||||
debug_info, services, user_is_local,
|
||||
utils::{self},
|
||||
Result,
|
||||
};
|
||||
use crate::{services, user_is_local};
|
||||
|
||||
pub struct Service {
|
||||
pub typing: RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>, // u64 is unix timestamp of timeout
|
||||
|
@ -25,7 +20,7 @@ pub struct Service {
|
|||
}
|
||||
|
||||
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 {
|
||||
typing: RwLock::new(BTreeMap::new()),
|
||||
last_typing_update: RwLock::new(BTreeMap::new()),
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use database::KvTree;
|
||||
use conduit::{utils, Error, Result};
|
||||
use database::{Database, Map};
|
||||
use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId};
|
||||
|
||||
use crate::{services, utils, Error, KeyValueDatabase, Result};
|
||||
use crate::services;
|
||||
|
||||
pub struct Data {
|
||||
userroomid_notificationcount: Arc<dyn KvTree>,
|
||||
userroomid_highlightcount: Arc<dyn KvTree>,
|
||||
roomuserid_lastnotificationread: Arc<dyn KvTree>,
|
||||
roomsynctoken_shortstatehash: Arc<dyn KvTree>,
|
||||
userroomid_joined: Arc<dyn KvTree>,
|
||||
pub(super) struct Data {
|
||||
userroomid_notificationcount: Arc<Map>,
|
||||
userroomid_highlightcount: Arc<Map>,
|
||||
roomuserid_lastnotificationread: Arc<Map>,
|
||||
roomsynctoken_shortstatehash: Arc<Map>,
|
||||
userroomid_joined: Arc<Map>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: &Arc<KeyValueDatabase>) -> Self {
|
||||
pub(super) fn new(db: &Arc<Database>) -> Self {
|
||||
Self {
|
||||
userroomid_notificationcount: db.userroomid_notificationcount.clone(),
|
||||
userroomid_highlightcount: db.userroomid_highlightcount.clone(),
|
||||
roomuserid_lastnotificationread: db.roomuserid_lastnotificationread.clone(),
|
||||
roomsynctoken_shortstatehash: db.roomsynctoken_shortstatehash.clone(),
|
||||
userroomid_joined: db.userroomid_joined.clone(),
|
||||
userroomid_notificationcount: db["userroomid_notificationcount"].clone(),
|
||||
userroomid_highlightcount: db["userroomid_highlightcount"].clone(),
|
||||
roomuserid_lastnotificationread: db["userroomid_highlightcount"].clone(), //< NOTE: known bug from conduit
|
||||
roomsynctoken_shortstatehash: db["roomsynctoken_shortstatehash"].clone(),
|
||||
userroomid_joined: db["userroomid_joined"].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, OwnedUserId, RoomId, UserId};
|
||||
|
||||
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