use crate::{
backend::NotificationStream,
model::{ConsumerGroupStatus, Event, NewEvent},
};
use async_trait::async_trait;
#[async_trait]
pub trait StreamBackend: Send + Sync {
async fn publish(&self, stream: &str, event: NewEvent) -> anyhow::Result<i64>;
async fn subscribe_stream(
&self,
stream: &str,
consumer_group: &str,
last_seq: Option<i64>,
) -> anyhow::Result<NotificationStream>;
async fn ack(&self, stream: &str, consumer_group: &str, seq: i64) -> anyhow::Result<()>;
async fn read_events(
&self,
stream: &str,
after_seq: i64,
limit: i64,
) -> anyhow::Result<Vec<Event>>;
async fn consumer_group_info(&self, stream: &str) -> anyhow::Result<Vec<ConsumerGroupStatus>>;
}