pub struct EventLog { /* private fields */ }Expand description
Sqlite-backed historical event store. Wraps a [Connection] in a
Mutex so it can be shared across the connector + axum tasks
without unsafe juggling. Reads are fast; writes serialise.
Implementations§
Source§impl EventLog
impl EventLog
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open or create a sqlite database at path. Runs the schema
migration on first call (idempotent).
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Open an in-memory database — used by tests.
Sourcepub fn append(&self, event: &ObservedEvent) -> Result<i64>
pub fn append(&self, event: &ObservedEvent) -> Result<i64>
Append an event. Returns the row id.
Sourcepub fn query_since(
&self,
topic: &str,
since_ts: &str,
limit: usize,
) -> Result<Vec<ObservedEvent>>
pub fn query_since( &self, topic: &str, since_ts: &str, limit: usize, ) -> Result<Vec<ObservedEvent>>
Read events for a topic since since_ts (ISO 8601). Newest-last.
Sourcepub fn prune(&self, policy: &RetentionPolicy) -> Result<usize>
pub fn prune(&self, policy: &RetentionPolicy) -> Result<usize>
Drop events older than the topic’s retention cutoff. Returns total rows deleted across all topics.
Sourcepub fn high_water(&self) -> Result<Option<(u64, u64)>>
pub fn high_water(&self) -> Result<Option<(u64, u64)>>
The largest (cursor, reset_epoch) ever logged, or None for an
empty log. A restarting connector seeds above both so its cursors
and epoch never fall back below what a client may still hold, even
when the host clock came up behind the previous run.