use arrow::record_batch::RecordBatch;
use async_trait::async_trait;
use crate::trigger::error::TriggerError;
use crate::trigger::ids::TopicId;
use crate::trigger::offset::Offset;
use crate::trigger::predicate::Predicate;
use crate::trigger::subscription::Subscription;
use crate::trigger::topic::TopicDefinition;
#[async_trait]
pub trait TriggerBroker: Send + Sync + 'static {
async fn register_topic(&self, topic: &TopicDefinition) -> Result<(), TriggerError>;
async fn drop_topic(&self, topic_id: TopicId) -> Result<(), TriggerError>;
async fn publish(
&self,
topic_id: TopicId,
batch: RecordBatch,
produced_at: chrono::DateTime<chrono::Utc>,
offset: u64,
) -> Result<Offset, TriggerError>;
async fn subscribe(
&self,
topic_id: TopicId,
predicate: Predicate,
from_offset: Option<Offset>,
) -> Result<Subscription, TriggerError>;
fn driver_kind(&self) -> BrokerKind;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BrokerKind {
InMemory,
JetStream,
}