feat: processed-event ledger, idempotent dispatch

This commit is contained in:
2026-10-26 00:17:28 +01:00
parent fa8e94817a
commit 5681d0c034
29 changed files with 610 additions and 24 deletions

View File

@@ -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()
}