saluki_core/components/decoders/
mod.rs

1//! Encoder component basics.
2
3use async_trait::async_trait;
4use saluki_error::GenericError;
5
6mod builder;
7pub use self::builder::DecoderBuilder;
8
9mod context;
10pub use self::context::DecoderContext;
11
12/// A decoder.
13///
14/// Decoders are the bridge between relays and the rest of the topology. They are responsible for decoding payloads into
15/// events that the rest of the topology can operate on. Decoders are generally specific to a particular
16/// system/protocol: while the _codec_ used by one decoder might be the same as another decoder, the format of the
17/// payload is likely to be highly contextual and so decoders cannot easily be swapped in and out.
18///
19/// Examples of typical decoders include OTLP and DogStatsD.
20#[async_trait]
21pub trait Decoder {
22    /// Runs the decoder.
23    ///
24    /// The decoder context provides access primarily to the payload stream, used to receive payloads sent to the decoder,
25    /// and the dispatcher, used to send events to the downstream component in the topology, as well as other
26    /// information such as the component context.
27    ///
28    /// Decoders are expected to run indefinitely until their payload stream is terminated, or an error occurs.
29    ///
30    /// # Errors
31    ///
32    /// If an unrecoverable error occurs while running, an error is returned.
33    async fn run(self: Box<Self>, context: DecoderContext) -> Result<(), GenericError>;
34}