saluki_core/components/sources/builder.rs
1use async_trait::async_trait;
2use memory_accounting::MemoryBounds;
3use saluki_error::GenericError;
4
5use super::Source;
6use crate::{components::ComponentContext, topology::OutputDefinition};
7
8/// A source builder.
9///
10/// Source builders are responsible for creating instances of [`Source`]s, as well as describing high-level aspects of
11/// the built source, such as the event outputs exposed by the source.
12#[async_trait]
13pub trait SourceBuilder: MemoryBounds {
14 /// Event outputs exposed by this source.
15 fn outputs(&self) -> &[OutputDefinition];
16
17 /// Builds an instance of the source.
18 ///
19 /// ## Errors
20 ///
21 /// If the source cannot be built for any reason, an error is returned.
22 async fn build(&self, context: ComponentContext) -> Result<Box<dyn Source + Send>, GenericError>;
23}