Expand description
Defines the Processor
trait for processing data within the carbon-core
pipeline.
The Processor
trait provides a standardized interface for handling various
types of data within the processing pipeline. It includes asynchronous
processing capabilities and supports metric tracking, enabling real-time
insights into the performance of individual processing stages.
§Key Concepts
- Processor: A trait that defines a single method,
process
, which asynchronously handles data of a specified type. This allows different stages of the pipeline to implement custom data handling logic. - Metrics: Metrics are collected during processing, offering visibility into processing duration, success, failure rates, and other relevant statistics.
§Usage
Implement the Processor
trait for any type that needs to handle specific
data in the pipeline. The trait allows you to define how data of a given
type is processed asynchronously, with the option to record metrics for
performance monitoring.
§Trait Definition
§Required Methods
process
: Handles processing of the specified data type. This method is asynchronous and should be implemented to define how data should be processed in your specific use case.
§Parameters
data
: An instance of the type specified byInputType
. This represents the data to be processed.metrics
: A vector ofMetrics
objects, allowing you to update and track various performance metrics.
§Returns
The process
method returns a CarbonResult<()>
, which indicates either
successful processing (Ok(())
) or an error.
§Notes
- This trait uses
async_trait
to enable asynchronous processing. Ensure your runtime environment supports asynchronous execution, such as a Tokio runtime, to fully utilize this trait. - When implementing the
process
method, consider which metrics are relevant to your data processing, and update those metrics accordingly to enable monitoring and alerting on key performance indicators.
Traits§
- Processor
- A trait for defining asynchronous data processing within the pipeline.