use std::sync::Arc;
use async_trait::async_trait;
use wyrd_queue::{BatchSink, ClientByteGuard, DurableBatchAck, SealedBatch, SinkError};
#[async_trait]
pub trait IngestTransport<G>: Send + Sync + 'static {
async fn insert_batch(&self, batch: &SealedBatch<G>) -> Result<DurableBatchAck, SinkError>;
}
pub struct BifrostIngestSink {
pub(crate) transport: Arc<dyn IngestTransport<ClientByteGuard>>,
}
impl BifrostIngestSink {
#[must_use]
#[cfg(feature = "internal")]
pub fn new(transport: Arc<dyn IngestTransport<ClientByteGuard>>) -> Self {
Self { transport }
}
}
#[async_trait]
impl BatchSink<ClientByteGuard> for BifrostIngestSink {
async fn send(
&self,
batch: &SealedBatch<ClientByteGuard>,
) -> Result<DurableBatchAck, SinkError> {
self.transport.insert_batch(batch).await
}
}