saluki_core/components/sources/
mod.rs

1//! Source component basics.
2
3use async_trait::async_trait;
4use saluki_error::GenericError;
5
6mod builder;
7pub use self::builder::SourceBuilder;
8
9mod context;
10pub use self::context::SourceContext;
11
12/// A source.
13///
14/// Sources are the initial entrypoint to a topology, where events are ingested from external systems, or sometimes
15/// generated. Examples of typical sources include StatsD, log files, and message queues.
16#[async_trait]
17pub trait Source {
18    /// Runs the source.
19    ///
20    /// The source context provides access primarily to the forwarder, used to send events to the next component(s) in
21    /// the topology, as well as other information such as the component context.
22    ///
23    /// Sources are expected to run indefinitely until their shutdown is triggered by the topology, or an error occurs.
24    ///
25    /// # Errors
26    ///
27    /// If an unrecoverable error occurs while running, an error is returned.
28    async fn run(self: Box<Self>, context: SourceContext) -> Result<(), GenericError>;
29}