use super::{EventKind, EventLog, EventRecord, IntoEvent};
#[derive(Debug, thiserror::Error)]
pub enum EventRepoError {
#[error("failed to publish event")]
PublishFailed,
}
#[async_trait::async_trait]
pub trait EventRepo {
async fn entries_since_position(
&self,
stream_name: impl AsRef<str> + Send,
position: i64,
) -> Result<EventLog, EventRepoError>;
async fn publish<EventCandidate>(&self, event: EventCandidate) -> Result<(), EventRepoError>
where
EventCandidate: IntoEvent + Send;
async fn last(
&self,
stream_name: impl AsRef<str> + Send,
kind: EventKind,
) -> Option<EventRecord>;
}