1use async_trait::async_trait;
2use futures::Stream;
3
4use crate::event::StreamEvent;
5use crate::namespace::Namespace;
6
7#[async_trait]
9pub trait WriteQueueBackend: Send + Sync {
10 async fn publish<N: Namespace>(&self, namespace: &N, payload: &[u8]) -> crate::Result<()>;
11}
12
13#[async_trait]
15pub trait ReadStreamBackend: Send + Sync {
16 async fn stream_exists<N: Namespace>(&self, namespace: &N) -> crate::Result<bool>;
18
19 async fn create_read_stream<N: Namespace>(
21 &self,
22 namespace: &N,
23 max_event_bytes: u64,
24 ) -> crate::Result<()>;
25
26 async fn publish_to_stream(&self, event: &StreamEvent) -> crate::Result<()>;
28
29 async fn populate_stream(&self, events: &[StreamEvent]) -> crate::Result<()>;
31
32 async fn subscribe_live<N: Namespace>(
34 &self,
35 namespace: &N,
36 ) -> crate::Result<impl Stream<Item = crate::Result<StreamEvent>> + Send>;
37}