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