intrepid_model/events/
event_repo.rs1use super::{EventKind, EventLog, EventRecord, IntoEvent};
2
3#[derive(Debug, thiserror::Error)]
5pub enum EventRepoError {
6 #[error("failed to publish event")]
8 PublishFailed,
9}
10
11#[async_trait::async_trait]
14pub trait EventRepo {
15 async fn entries_since_position(
17 &self,
18 stream_name: impl AsRef<str> + Send,
19 position: i64,
20 ) -> Result<EventLog, EventRepoError>;
21
22 async fn publish<EventCandidate>(&self, event: EventCandidate) -> Result<(), EventRepoError>
24 where
25 EventCandidate: IntoEvent + Send;
26
27 async fn last(
29 &self,
30 stream_name: impl AsRef<str> + Send,
31 kind: EventKind,
32 ) -> Option<EventRecord>;
33}