pub struct ControlledMemoryStore { /* private fields */ }testing only.Expand description
A MemoryStore whose linked chunk writes can be blocked.
This is meant for tests that need to control when, or whether, the event cache persists its data: for instance to check what the rest of the SDK does while the store is slow, or when it returns an error.
Only EventCacheStore::handle_linked_chunk_updates is affected. All the
other methods are forwarded to the inner MemoryStore as is.
Implementations§
Source§impl ControlledMemoryStore
impl ControlledMemoryStore
Sourcepub fn block_writes(&self)
pub fn block_writes(&self)
Block linked chunk writes until Self::unblock_writes is called.
A blocked write still counts as started for
Self::wait_for_write_to_start.
Sourcepub fn unblock_writes(&self)
pub fn unblock_writes(&self)
Let the blocked linked chunk writes, and the next ones, go through.
Sourcepub async fn wait_for_write_to_start(&self)
pub async fn wait_for_write_to_start(&self)
Wait until a linked chunk write starts.
Returns at once if a write has started since the last call.
Sourcepub async fn wait_for_write_to_finish(&self)
pub async fn wait_for_write_to_finish(&self)
Wait until a linked chunk write finishes.
Returns at once if a write has finished since the last call.
Trait Implementations§
Source§impl Clone for ControlledMemoryStore
impl Clone for ControlledMemoryStore
Source§impl Debug for ControlledMemoryStore
impl Debug for ControlledMemoryStore
Source§impl Default for ControlledMemoryStore
impl Default for ControlledMemoryStore
Source§impl EventCacheStore for ControlledMemoryStore
impl EventCacheStore for ControlledMemoryStore
Source§type Error = EventCacheStoreError
type Error = EventCacheStoreError
Source§fn handle_linked_chunk_updates<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
updates: Vec<Update<Event, Gap>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_linked_chunk_updates<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
updates: Vec<Update<Event, Gap>>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update reflects an operation that has happened inside a linked
chunk. The linked chunk is used by the event cache to store the events
in-memory. This method aims at forwarding this update inside this store.Source§fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn reopen<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reopen<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Self::close(), re-acquiring database
connections.Source§fn try_take_leased_lock<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
lease_duration_ms: u32,
key: &'life1 str,
holder: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CrossProcessLockGeneration>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn try_take_leased_lock<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
lease_duration_ms: u32,
key: &'life1 str,
holder: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CrossProcessLockGeneration>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn load_all_chunks_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkMetadata>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_all_chunks_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkMetadata>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
LinkedChunkId. Read moreSource§fn load_last_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(Option<RawChunk<Event, Gap>>, ChunkIdentifierGenerator), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_last_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
) -> Pin<Box<dyn Future<Output = Result<(Option<RawChunk<Event, Gap>>, ChunkIdentifierGenerator), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
LinkedChunk holding all events of the room
identified by room_id. Read moreSource§fn load_previous_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
before_chunk_identifier: ChunkIdentifier,
) -> Pin<Box<dyn Future<Output = Result<Option<RawChunk<Event, Gap>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_previous_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
before_chunk_identifier: ChunkIdentifier,
) -> Pin<Box<dyn Future<Output = Result<Option<RawChunk<Event, Gap>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
before_chunk_identifier
of the LinkedChunk holding all events of the room identified by
room_id Read moreSource§fn load_thread_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
thread_id: &'life2 EventId,
insert_default_if_missing: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<ThreadInfo>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn load_thread_info<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
thread_id: &'life2 EventId,
insert_default_if_missing: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<ThreadInfo>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn update_thread_info<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
thread_id: &'life2 EventId,
thread_info: &'life3 ThreadInfo,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn update_thread_info<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
thread_id: &'life2 EventId,
thread_info: &'life3 ThreadInfo,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn clear_all_events<'life0, 'life1, 'async_trait>(
&'life0 self,
room_id: Option<&'life1 RoomId>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn clear_all_events<'life0, 'life1, 'async_trait>(
&'life0 self,
room_id: Option<&'life1 RoomId>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn filter_duplicated_events<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
events: Vec<OwnedEventId>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(OwnedEventId, Position)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn filter_duplicated_events<'life0, 'life1, 'async_trait>(
&'life0 self,
linked_chunk_id: LinkedChunkId<'life1>,
events: Vec<OwnedEventId>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(OwnedEventId, Position)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn find_event<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event_id: &'life2 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn find_event<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event_id: &'life2 EventId,
) -> Pin<Box<dyn Future<Output = Result<Option<Event>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn find_event_relations<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event_id: &'life2 EventId,
filters: Option<&'life3 [RelationType]>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Event, Option<Position>)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn find_event_relations<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event_id: &'life2 EventId,
filters: Option<&'life3 [RelationType]>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(Event, Option<Position>)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn get_room_events<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event_type: Option<&'life2 str>,
session_id: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn get_room_events<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event_type: Option<&'life2 str>,
session_id: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn save_event<'life0, 'life1, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_event<'life0, 'life1, 'async_trait>(
&'life0 self,
room_id: &'life1 RoomId,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for ControlledMemoryStore
impl RefUnwindSafe for ControlledMemoryStore
impl Send for ControlledMemoryStore
impl Sync for ControlledMemoryStore
impl Unpin for ControlledMemoryStore
impl UnsafeUnpin for ControlledMemoryStore
impl UnwindSafe for ControlledMemoryStore
Blanket Implementations§
impl<T> AsyncTraitDeps for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more