rust_rule_engine/streaming/
mod.rs

1//! Rule Streaming Engine - Real-time Event Processing
2//!
3//! This module provides real-time rule execution capabilities for streaming data,
4//! including time-based windows, event aggregation, and continuous rule evaluation.
5//!
6//! ## Features
7//!
8//! - **🔄 Continuous Processing**: Non-stop rule evaluation on incoming events
9//! - **⏰ Time Windows**: Sliding and tumbling window aggregations
10//! - **📊 Stream Analytics**: Count, sum, average, min/max over time windows
11//! - **🎯 Event Filtering**: Pattern matching and event correlation
12//! - **⚡ High Throughput**: Async processing with backpressure handling
13//!
14//! ## Example
15//!
16//! ```rust,ignore
17//! use rust_rule_engine::streaming::*;
18//!
19//! let mut stream_engine = StreamRuleEngine::new()
20//!     .with_window_size(Duration::from_secs(60))
21//!     .with_buffer_size(1000);
22//!
23//! // Define streaming rule
24//! let rule = r#"
25//! rule "HighFrequencyTrading" {
26//!     when
27//!         stream(TradeEvent, 5s).count() > 100
28//!     then
29//!         AlertService.trigger("High frequency detected");
30//! }
31//! "#;
32//!
33//! stream_engine.add_rule(rule).await?;
34//! stream_engine.start().await?;
35//! ```
36
37#[cfg(feature = "streaming")]
38pub mod aggregator;
39#[cfg(feature = "streaming")]
40pub mod engine;
41#[cfg(feature = "streaming")]
42pub mod event;
43#[cfg(feature = "streaming")]
44pub mod window;
45
46#[cfg(feature = "streaming")]
47pub use aggregator::{AggregationType, Aggregator};
48#[cfg(feature = "streaming")]
49pub use engine::StreamRuleEngine;
50#[cfg(feature = "streaming")]
51pub use event::{EventMetadata, StreamEvent};
52#[cfg(feature = "streaming")]
53pub use window::{TimeWindow, WindowManager, WindowType};
54
55/// Re-export for non-streaming builds
56#[cfg(not(feature = "streaming"))]
57pub struct StreamRuleEngine;
58
59#[cfg(not(feature = "streaming"))]
60impl StreamRuleEngine {
61    /// Placeholder for non-streaming builds
62    pub fn new() -> Self {
63        StreamRuleEngine
64    }
65}