Skip to main content

SegmentProcessor

Trait SegmentProcessor 

pub trait SegmentProcessor: Send {
    // Required methods
    fn name(&self) -> &'static str;
    fn process(
        &mut self,
        data: SegmentData,
    ) -> Pin<Box<dyn Future<Output = Result<SegmentData, ProcessError>> + Send + '_>>;

    // Provided methods
    fn initialize(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>> { ... }
    fn finalize_dump(
        &mut self,
        completion: &DumpCompletion,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>> { ... }
}
Available on crate features dial9 and pipeline only.
Expand description

A single step in the segment processing pipeline.

Implementations handle one concern: compress, symbolize, upload, etc. The driver calls processors in sequence for each segment.

§Panic safety

The driver catches panics from process() and skips the panicking segment. The same processor instance is reused for subsequent segments, so implementations must remain in a valid state after a panic (i.e., no partially-updated invariants that would cause incorrect behavior on the next call).

Required Methods§

fn name(&self) -> &'static str

Human-readable name for this processor (used in metrics).

fn process( &mut self, data: SegmentData, ) -> Pin<Box<dyn Future<Output = Result<SegmentData, ProcessError>> + Send + '_>>

Process a segment, transforming or consuming its data. Returns the (possibly modified) data for the next processor, or an error to skip this segment.

Provided Methods§

fn initialize( &mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>

Initialize this processor on the worker’s Tokio runtime before the pipeline begins processing segments.

Drivers should call this once before process and abort pipeline construction if it returns an error. Default: no-op.

The same panic-safety contract as process applies.

fn finalize_dump( &mut self, completion: &DumpCompletion, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>>

Called once per finished dump in triggered mode (see crate::dump), in pipeline order, so stages can flush any per-dump state they accumulated. Return the S3 key of a manifest written for this dump, or None; the last Some across the pipeline lands on DumpReceipt::manifest_key.

Default: no-op returning None. Never called in continuous mode. The same panic-safety contract as process() applies.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§