fix: per-handler claim lease in ledger, nats max_deliver, pin handler names
This commit is contained in:
@@ -9,6 +9,13 @@ use crate::models::{
|
||||
};
|
||||
use crate::value_objects::SocialIdentity;
|
||||
|
||||
/// One `processed_events` row.
|
||||
pub(super) struct LedgerRow {
|
||||
pub(super) done: bool,
|
||||
pub(super) started_at: chrono::NaiveDateTime,
|
||||
pub(super) processed_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub(super) enum FollowState {
|
||||
Pending,
|
||||
@@ -64,7 +71,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>>,
|
||||
pub(super) processed_events: RwLock<HashMap<(Uuid, String), LedgerRow>>,
|
||||
}
|
||||
|
||||
impl InMemoryStore {
|
||||
@@ -128,17 +135,22 @@ impl InMemoryStore {
|
||||
self.processed_events.read().unwrap().len()
|
||||
}
|
||||
|
||||
/// Inserts a ledger row with an explicit timestamp (for retention tests).
|
||||
/// Inserts a ledger row with explicit timestamps (retention and lease tests).
|
||||
pub fn seed_processed_event(
|
||||
&self,
|
||||
id: &crate::events::EventId,
|
||||
handler: &str,
|
||||
processed_at: chrono::NaiveDateTime,
|
||||
done: bool,
|
||||
at: chrono::NaiveDateTime,
|
||||
) {
|
||||
self.processed_events
|
||||
.write()
|
||||
.unwrap()
|
||||
.insert((id.value(), handler.to_owned()), processed_at);
|
||||
self.processed_events.write().unwrap().insert(
|
||||
(id.value(), handler.to_owned()),
|
||||
LedgerRow {
|
||||
done,
|
||||
started_at: at,
|
||||
processed_at: at,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub fn refresh_session_count(&self) -> usize {
|
||||
|
||||
Reference in New Issue
Block a user