StreamPipelineBuilder

Struct StreamPipelineBuilder 

Source
pub struct StreamPipelineBuilder { /* private fields */ }
Expand description

Builder for constructing stream processing pipelines

Provides a fluent API for configuring all aspects of a stream processing pipeline including windows, watermarks, state backends, and operators.

§Example

use processor::pipeline::StreamPipelineBuilder;
use processor::config::{WindowConfig, StateBackend};
use std::time::Duration;

let pipeline = StreamPipelineBuilder::new()
    .with_name("my-pipeline")
    .with_description("Processes user events")
    .with_parallelism(8)
    .with_window(WindowConfig::tumbling(60_000))
    .with_watermark_delay(Duration::from_secs(10))
    .with_state_backend(StateBackend::Memory)
    .with_buffer_size(50_000)
    .with_tag("production")
    .with_tag("user-events")
    .build()?;

Implementations§

Source§

impl StreamPipelineBuilder

Source

pub fn new() -> Self

Create a new pipeline builder with default configuration

Source

pub fn with_name<S: Into<String>>(self, name: S) -> Self

Set the pipeline name

§Example
let builder = StreamPipelineBuilder::new()
    .with_name("user-event-processor");
Source

pub fn with_description<S: Into<String>>(self, description: S) -> Self

Set the pipeline description

Source

pub fn with_tag<S: Into<String>>(self, tag: S) -> Self

Add a tag to the pipeline

Source

pub fn with_tags<I, S>(self, tags: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple tags to the pipeline

Source

pub fn with_parallelism(self, parallelism: usize) -> Self

Set the number of parallel processing workers

§Example
let builder = StreamPipelineBuilder::new()
    .with_parallelism(16);
Source

pub fn with_buffer_size(self, buffer_size: usize) -> Self

Set the event buffer size

Source

pub fn with_metrics(self, enabled: bool) -> Self

Enable or disable metrics collection

Source

pub fn with_window(self, window: WindowConfig) -> Self

Set the window configuration

§Example
let builder = StreamPipelineBuilder::new()
    .with_window(WindowConfig::tumbling(60_000));
Source

pub fn with_tumbling_window(self, size_ms: u64) -> Self

Set a tumbling window with the given size

§Arguments
  • size_ms - Window size in milliseconds
§Example
let builder = StreamPipelineBuilder::new()
    .with_tumbling_window(60_000); // 1 minute windows
Source

pub fn with_sliding_window(self, size_ms: u64, slide_ms: u64) -> Self

Set a sliding window with the given size and slide

§Arguments
  • size_ms - Window size in milliseconds
  • slide_ms - Slide interval in milliseconds
§Example
let builder = StreamPipelineBuilder::new()
    .with_sliding_window(300_000, 60_000); // 5 min window, 1 min slide
Source

pub fn with_session_window(self, gap_ms: u64) -> Self

Set a session window with the given gap

§Arguments
  • gap_ms - Session gap in milliseconds
§Example
let builder = StreamPipelineBuilder::new()
    .with_session_window(300_000); // 5 minute session gap
Source

pub fn with_allowed_lateness(self, lateness_ms: u64) -> Self

Set allowed lateness for late events

Source

pub fn with_drop_late_events(self, drop: bool) -> Self

Set whether to drop late events

Source

pub fn with_watermark_config(self, watermark: WatermarkConfig) -> Self

Set the watermark configuration

Source

pub fn with_watermark_delay(self, delay: Duration) -> Self

Set the watermark delay (max out-of-orderness)

§Example
let builder = StreamPipelineBuilder::new()
    .with_watermark_delay(Duration::from_secs(10));
Source

pub fn with_idle_timeout(self, timeout: Duration) -> Self

Set the idle source timeout

Source

pub fn with_watermark_interval(self, interval: Duration) -> Self

Set the watermark update interval

Source

pub fn with_state_backend(self, backend: StateBackend) -> Self

Set the state backend

§Example
let builder = StreamPipelineBuilder::new()
    .with_state_backend(StateBackend::Memory);
Source

pub fn with_state_path<S: Into<PathBuf>>(self, path: S) -> Self

Set the state storage path (for file-based backends)

Source

pub fn with_checkpoint_interval(self, interval: Duration) -> Self

Set the checkpoint interval

Source

pub fn with_incremental_checkpoints(self, enabled: bool) -> Self

Enable or disable incremental checkpoints

Source

pub fn with_checkpoint_retention(self, count: usize) -> Self

Set the number of checkpoints to retain

Source

pub fn with_state_ttl(self, ttl: Duration) -> Self

Set state TTL (time-to-live)

Source

pub fn with_max_state_size(self, size_bytes: u64) -> Self

Set maximum state size for memory backends

Source

pub fn with_state_compression(self, enabled: bool) -> Self

Enable state compression

Source

pub fn with_percentiles(self, percentiles: Vec<u8>) -> Self

Set aggregation percentiles to compute

Source

pub fn with_histogram_buckets(self, buckets: Vec<f64>) -> Self

Set histogram buckets

Source

pub fn with_min_samples(self, min: usize) -> Self

Set minimum samples required for aggregation

Source

pub fn with_max_samples(self, max: usize) -> Self

Set maximum samples to keep in memory

Source

pub fn with_outlier_removal(self, threshold: f64) -> Self

Enable outlier detection and removal

Source

pub fn with_deduplication(self, enabled: bool, ttl: Duration) -> Self

Enable event deduplication

§Example
let builder = StreamPipelineBuilder::new()
    .with_deduplication(true, Duration::from_secs(3600));
Source

pub fn with_deduplication_config(self, config: DeduplicationConfig) -> Self

Set the deduplication configuration

§Example
let dedup_config = DeduplicationConfig::new()
    .enabled()
    .with_ttl(Duration::from_secs(7200))
    .with_strategy(DeduplicationStrategy::EventId);

let builder = StreamPipelineBuilder::new()
    .with_deduplication_config(dedup_config);
Source

pub fn with_deduplication_ttl(self, ttl: Duration) -> Self

Set the deduplication TTL

§Example
let builder = StreamPipelineBuilder::new()
    .with_deduplication_ttl(Duration::from_secs(3600));
Source

pub fn with_deduplication_strategy( self, strategy: DeduplicationStrategy, ) -> Self

Set the deduplication strategy

§Example
let builder = StreamPipelineBuilder::new()
    .with_deduplication_strategy(DeduplicationStrategy::ContentHash);
Source

pub fn with_deduplication_redis_prefix<S: Into<String>>(self, prefix: S) -> Self

Set the Redis key prefix for deduplication

§Example
let builder = StreamPipelineBuilder::new()
    .with_deduplication_redis_prefix("myapp:dedup");
Source

pub fn with_normalization(self, enabled: bool, interval: Duration) -> Self

Enable time-series normalization

§Example
let builder = StreamPipelineBuilder::new()
    .with_normalization(true, Duration::from_secs(5));
Source

pub fn with_normalization_config(self, config: NormalizationConfig) -> Self

Set the normalization configuration

§Example
let norm_config = NormalizationConfig::new()
    .enabled()
    .with_interval(Duration::from_secs(5))
    .with_fill_strategy(FillStrategy::LinearInterpolation)
    .with_alignment(AlignmentStrategy::Start);

let builder = StreamPipelineBuilder::new()
    .with_normalization_config(norm_config);
Source

pub fn with_normalization_interval(self, interval: Duration) -> Self

Set the normalization interval

§Example
let builder = StreamPipelineBuilder::new()
    .with_normalization_interval(Duration::from_secs(5));
Source

pub fn with_fill_strategy(self, strategy: FillStrategy) -> Self

Set the fill strategy for normalization

§Example
let builder = StreamPipelineBuilder::new()
    .with_fill_strategy(FillStrategy::LinearInterpolation);
Source

pub fn with_alignment_strategy(self, strategy: AlignmentStrategy) -> Self

Set the alignment strategy for normalization

§Example
let builder = StreamPipelineBuilder::new()
    .with_alignment_strategy(AlignmentStrategy::Start);
Source

pub fn with_normalization_buffer_size(self, size: usize) -> Self

Set the normalization buffer size

§Example
let builder = StreamPipelineBuilder::new()
    .with_normalization_buffer_size(2000);
Source

pub fn with_interpolation_max_gap(self, gap: Duration) -> Self

Set the interpolation max gap for normalization

§Example
let builder = StreamPipelineBuilder::new()
    .with_interpolation_max_gap(Duration::from_secs(10));
Source

pub fn with_normalization_outlier_detection(self, threshold: f64) -> Self

Enable outlier detection in normalization

§Example
let builder = StreamPipelineBuilder::new()
    .with_normalization_outlier_detection(3.0);
Source

pub fn build(self) -> Result<StreamPipeline>

Build the pipeline with the configured settings

§Errors

Returns an error if the configuration is invalid.

§Example
let pipeline = StreamPipelineBuilder::new()
    .with_name("my-pipeline")
    .with_parallelism(4)
    .build()?;

Trait Implementations§

Source§

impl Default for StreamPipelineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more