use faucet_stream::CsvOptions;
use faucet_stream::Pipeline;
use faucet_stream::sink::file::{FileSink, FileSinkConfig, IfExists};
use faucet_stream::source::webhook::{WebhookSource, WebhookSourceConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let source = WebhookSource::new(
WebhookSourceConfig::new()
.listen_addr("127.0.0.1:9090")
.path("/inbox")
.max_payloads(5_000)
.timeout_secs(120),
);
let sink = FileSink::new(
FileSinkConfig::new("webhooks.csv")
.if_exists(IfExists::Append)
.csv(CsvOptions {
delimiter: ";".into(),
has_headers: true,
..CsvOptions::default()
}),
)?;
let result = Pipeline::new(&source, &sink).run().await?;
println!(
"captured {} webhook payloads into webhooks.csv",
result.records_written
);
Ok(())
}