feat: processed-event ledger, idempotent dispatch
This commit is contained in:
@@ -64,6 +64,7 @@ pub struct InMemoryStore {
|
||||
pub(super) import_profiles: RwLock<HashMap<Uuid, ImportProfile>>,
|
||||
pub(super) follows: RwLock<Vec<(Uuid, SocialIdentity, FollowState)>>,
|
||||
pub(super) blocked: RwLock<Vec<(Uuid, SocialIdentity)>>,
|
||||
pub(super) processed_events: RwLock<HashMap<(Uuid, String), chrono::NaiveDateTime>>,
|
||||
}
|
||||
|
||||
impl InMemoryStore {
|
||||
@@ -85,6 +86,7 @@ impl InMemoryStore {
|
||||
import_profiles: RwLock::default(),
|
||||
follows: RwLock::default(),
|
||||
blocked: RwLock::default(),
|
||||
processed_events: RwLock::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -122,6 +124,23 @@ impl InMemoryStore {
|
||||
self.import_sessions.read().unwrap().len()
|
||||
}
|
||||
|
||||
pub fn processed_event_count(&self) -> usize {
|
||||
self.processed_events.read().unwrap().len()
|
||||
}
|
||||
|
||||
/// Inserts a ledger row with an explicit timestamp (for retention tests).
|
||||
pub fn seed_processed_event(
|
||||
&self,
|
||||
id: &crate::events::EventId,
|
||||
handler: &str,
|
||||
processed_at: chrono::NaiveDateTime,
|
||||
) {
|
||||
self.processed_events
|
||||
.write()
|
||||
.unwrap()
|
||||
.insert((id.value(), handler.to_owned()), processed_at);
|
||||
}
|
||||
|
||||
pub fn refresh_session_count(&self) -> usize {
|
||||
self.refresh_sessions.read().unwrap().len()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user