feat: atomic review writes with events
This commit is contained in:
@@ -72,6 +72,7 @@ pub struct InMemoryStore {
|
||||
pub(super) follows: RwLock<Vec<(Uuid, SocialIdentity, FollowState)>>,
|
||||
pub(super) blocked: RwLock<Vec<(Uuid, SocialIdentity)>>,
|
||||
pub(super) processed_events: RwLock<HashMap<(Uuid, String), LedgerRow>>,
|
||||
pub(super) recorded_events: RwLock<Vec<crate::events::DomainEvent>>,
|
||||
}
|
||||
|
||||
impl InMemoryStore {
|
||||
@@ -94,6 +95,7 @@ impl InMemoryStore {
|
||||
follows: RwLock::default(),
|
||||
blocked: RwLock::default(),
|
||||
processed_events: RwLock::default(),
|
||||
recorded_events: RwLock::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -103,6 +105,19 @@ impl InMemoryStore {
|
||||
store
|
||||
}
|
||||
|
||||
/// Events recorded atomically with a change (the outbox rows the sqlite
|
||||
/// adapter would have written in the same transaction), in write order.
|
||||
pub fn recorded_events(&self) -> Vec<crate::events::DomainEvent> {
|
||||
self.recorded_events.read().unwrap().clone()
|
||||
}
|
||||
|
||||
pub(super) fn record_events(&self, events: &[crate::events::DomainEvent]) {
|
||||
self.recorded_events
|
||||
.write()
|
||||
.unwrap()
|
||||
.extend_from_slice(events);
|
||||
}
|
||||
|
||||
pub fn movie_count(&self) -> usize {
|
||||
self.movies.read().unwrap().len()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user