Files
zap-stream-core/src/pipeline/builder.rs
2024-03-25 10:32:03 +00:00

22 lines
569 B
Rust

use tokio::sync::mpsc::UnboundedReceiver;
use crate::ingress::ConnectionInfo;
use crate::pipeline::runner::PipelineRunner;
use crate::webhook::Webhook;
#[derive(Clone)]
pub struct PipelineBuilder {
webhook: Webhook,
}
impl PipelineBuilder {
pub fn new(webhook: Webhook) -> Self {
Self { webhook }
}
pub async fn build_for(&self, info: ConnectionInfo, recv: UnboundedReceiver<bytes::Bytes>) -> Result<PipelineRunner, anyhow::Error> {
let config = self.webhook.start(info).await?;
Ok(PipelineRunner::new(config, recv))
}
}