saluki_core/components/relays/mod.rs
1//! Relay component basics.
2
3use async_trait::async_trait;
4use saluki_error::GenericError;
5
6mod builder;
7pub use self::builder::RelayBuilder;
8
9mod context;
10pub use self::context::RelayContext;
11
12/// A relay.
13///
14/// Relays are the initial entrypoint to a topology for accepting raw payloads. Unlike sources,
15/// which decode/parse incoming data into events, relays simply accept raw bytes from the network and
16/// output them as payloads for downstream processing.
17#[async_trait]
18pub trait Relay {
19 /// Runs the relay.
20 ///
21 /// The relay context provides access primarily to the payloads dispatcher, used to send raw payloads
22 /// to the next component(s) in the topology, as well as other information such as the component context.
23 ///
24 /// Relays are expected to run indefinitely until their shutdown is triggered by the topology, or an error occurs.
25 ///
26 /// # Errors
27 ///
28 /// If an unrecoverable error occurs while running, an error is returned.
29 async fn run(self: Box<Self>, context: RelayContext) -> Result<(), GenericError>;
30}