-
Notifications
You must be signed in to change notification settings - Fork 289
feat: Implement cross-process lock for the EventCache
#4192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f2c3ae6
46f22fb
a8f244a
05f275d
170ccdf
a1ab486
b269b8a
a124f1a
42d0dc4
c2e99b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ use tokio::sync::{broadcast, Mutex, RwLock}; | |
use tracing::warn; | ||
|
||
use crate::{ | ||
event_cache_store::{DynEventCacheStore, IntoEventCacheStore}, | ||
event_cache_store, | ||
rooms::{normal::RoomInfoNotableUpdate, RoomInfo, RoomState}, | ||
MinimalRoomMemberEvent, Room, RoomStateFilter, SessionMeta, | ||
}; | ||
|
@@ -489,7 +489,7 @@ pub struct StoreConfig { | |
#[cfg(feature = "e2e-encryption")] | ||
pub(crate) crypto_store: Arc<DynCryptoStore>, | ||
pub(crate) state_store: Arc<DynStateStore>, | ||
pub(crate) event_cache_store: Arc<DynEventCacheStore>, | ||
pub(crate) event_cache_store: event_cache_store::EventCacheStoreLock, | ||
} | ||
|
||
#[cfg(not(tarpaulin_include))] | ||
|
@@ -507,8 +507,11 @@ impl StoreConfig { | |
#[cfg(feature = "e2e-encryption")] | ||
crypto_store: matrix_sdk_crypto::store::MemoryStore::new().into_crypto_store(), | ||
state_store: Arc::new(MemoryStore::new()), | ||
event_cache_store: crate::event_cache_store::MemoryStore::new() | ||
.into_event_cache_store(), | ||
event_cache_store: event_cache_store::EventCacheStoreLock::new( | ||
event_cache_store::MemoryStore::new(), | ||
"default-key".to_owned(), | ||
"matrix-sdk-base".to_owned(), | ||
Comment on lines
+512
to
+513
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The values provided here are scary, and should be controllable by the callers, otherwise it's not possible to distinguish a process from another. The key could be a constant used everywhere in the codebase (maybe buried into a single place, and then passed around — or buried a single time when creating an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to address that as a follow-up PR: I want to introduce a "process holder name" inside the client that can be used by all cross-process lock, otherwise things start to be really clumsy. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bnjbvr and I have agreed to remove these values with a configuration in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it is, #4224 |
||
), | ||
} | ||
} | ||
|
||
|
@@ -528,8 +531,15 @@ impl StoreConfig { | |
} | ||
|
||
/// Set a custom implementation of an `EventCacheStore`. | ||
pub fn event_cache_store(mut self, event_cache_store: impl IntoEventCacheStore) -> Self { | ||
self.event_cache_store = event_cache_store.into_event_cache_store(); | ||
/// | ||
/// The `key` and `holder` arguments represent the key and holder inside the | ||
/// [`CrossProcessStoreLock::new`][matrix_sdk_common::store_locks::CrossProcessStoreLock::new]. | ||
pub fn event_cache_store<S>(mut self, event_cache_store: S, key: String, holder: String) -> Self | ||
Hywan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
where | ||
S: event_cache_store::IntoEventCacheStore, | ||
{ | ||
self.event_cache_store = | ||
event_cache_store::EventCacheStoreLock::new(event_cache_store, key, holder); | ||
self | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.