courier/sources/mod.rs
1use async_trait::async_trait;
2use tokio::sync::mpsc::Sender;
3use tokio_util::sync::CancellationToken;
4
5use crate::envelope::Envelope;
6use crate::observability::NodeCtx;
7
8pub mod api;
9pub mod http_webhook;
10pub mod kafka;
11mod retry;
12pub mod sql;
13
14/// A pipeline source.
15///
16/// Drives its own cadence (polling, streaming, event-driven) and pushes
17/// envelopes into `tx`. When `cancel` fires, the implementation must exit
18/// promptly; dropping `tx` on exit signals downstream stages to drain.
19#[async_trait]
20pub trait Source: Send + Sync {
21 fn id(&self) -> &str;
22
23 /// Attach the per-node observability context. Called by
24 /// `spawn_pipeline` after the source is built but before it runs.
25 /// Default no-op for custom sources that do not use `SourceCtx`.
26 fn set_node_ctx(&mut self, _ctx: NodeCtx) {}
27
28 async fn run(self: Box<Self>, tx: Sender<Envelope>, cancel: CancellationToken);
29}