mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
add constructor for lazy-loading service
This commit is contained in:
parent
3b28d0cfda
commit
a083ff9200
2 changed files with 11 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap},
|
collections::BTreeMap,
|
||||||
sync::{Arc, Mutex as StdMutex, OnceLock},
|
sync::{Arc, Mutex as StdMutex, OnceLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -88,10 +88,7 @@ impl Services {
|
||||||
typing: rooms::edus::typing::Service::new(),
|
typing: rooms::edus::typing::Service::new(),
|
||||||
},
|
},
|
||||||
event_handler: rooms::event_handler::Service,
|
event_handler: rooms::event_handler::Service,
|
||||||
lazy_loading: rooms::lazy_loading::Service {
|
lazy_loading: rooms::lazy_loading::Service::new(db),
|
||||||
db,
|
|
||||||
lazy_load_waiting: Mutex::new(HashMap::new()),
|
|
||||||
},
|
|
||||||
metadata: db,
|
metadata: db,
|
||||||
outlier: db,
|
outlier: db,
|
||||||
pdu_metadata: rooms::pdu_metadata::Service {
|
pdu_metadata: rooms::pdu_metadata::Service {
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ mod data;
|
||||||
pub(crate) use data::Data;
|
pub(crate) use data::Data;
|
||||||
|
|
||||||
pub(crate) struct Service {
|
pub(crate) struct Service {
|
||||||
pub(crate) db: &'static dyn Data,
|
db: &'static dyn Data,
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub(crate) lazy_load_waiting: Mutex<
|
lazy_load_waiting: Mutex<
|
||||||
HashMap<
|
HashMap<
|
||||||
(OwnedUserId, OwnedDeviceId, OwnedRoomId, PduCount),
|
(OwnedUserId, OwnedDeviceId, OwnedRoomId, PduCount),
|
||||||
HashSet<OwnedUserId>,
|
HashSet<OwnedUserId>,
|
||||||
|
|
@ -23,6 +23,13 @@ pub(crate) struct Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
|
pub(crate) fn new(db: &'static dyn Data) -> Self {
|
||||||
|
Self {
|
||||||
|
db,
|
||||||
|
lazy_load_waiting: Mutex::new(HashMap::new()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub(crate) fn lazy_load_was_sent_before(
|
pub(crate) fn lazy_load_was_sent_before(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue