pub struct EventLog { /* private fields */ }Expand description
Append-only SQLite event log.
Cheap to clone; internally holds an Arc<Mutex<Connection>> so that
concurrent calls serialise on the underlying connection.
Implementations§
Source§impl EventLog
impl EventLog
Sourcepub async fn in_memory() -> Result<Self, ARCPError>
pub async fn in_memory() -> Result<Self, ARCPError>
Open an in-memory event log. Convenient for tests.
§Errors
Returns ARCPError::Storage if SQLite cannot create the in-memory
database or apply the schema.
Sourcepub async fn open(path: impl AsRef<Path>) -> Result<Self, ARCPError>
pub async fn open(path: impl AsRef<Path>) -> Result<Self, ARCPError>
Open (or create) an event log backed by path.
§Errors
Returns ARCPError::Storage if SQLite cannot open or create the
file or apply the schema.
Sourcepub async fn append(
&self,
envelope: &Envelope,
) -> Result<AppendOutcome, ARCPError>
pub async fn append( &self, envelope: &Envelope, ) -> Result<AppendOutcome, ARCPError>
Append one envelope to the log. Idempotent on (session_id, id).
§Errors
Returns ARCPError::Serialization if the envelope cannot be
serialised, ARCPError::Storage for any underlying SQLite error.
Sourcepub async fn list(
&self,
session_id: &str,
after_rowid: i64,
limit: i64,
) -> Result<Vec<LoggedEvent>, ARCPError>
pub async fn list( &self, session_id: &str, after_rowid: i64, limit: i64, ) -> Result<Vec<LoggedEvent>, ARCPError>
List rows for session_id strictly after after_rowid, in replay
order, capped at limit rows.
Pass after_rowid = 0 to start from the beginning.
§Errors
Returns ARCPError::Storage for any underlying SQLite error.
Sourcepub async fn get_by_id(
&self,
id: &str,
) -> Result<Option<LoggedEvent>, ARCPError>
pub async fn get_by_id( &self, id: &str, ) -> Result<Option<LoggedEvent>, ARCPError>
Fetch a single row by message id.
§Errors
Returns ARCPError::Storage for any underlying SQLite error.