fluxus_transformers/operator/
mod.rs

1use async_trait::async_trait;
2use fluxus_utils::models::{Record, StreamResult};
3
4mod builder;
5mod filter;
6mod map;
7mod window_reduce;
8
9pub use builder::OperatorBuilder;
10pub use filter::FilterOperator;
11pub use map::MapOperator;
12pub use window_reduce::WindowReduceOperator;
13
14/// Operator trait defines the interface for stream processing operators
15#[async_trait]
16pub trait Operator<In, Out>: Send {
17    /// Initialize the operator
18    async fn init(&mut self) -> StreamResult<()>;
19
20    /// Process a single record and return zero or more output records
21    async fn process(&mut self, record: Record<In>) -> StreamResult<Vec<Record<Out>>>;
22
23    /// Called when a window is triggered (if windowing is enabled)
24    async fn on_window_trigger(&mut self) -> StreamResult<Vec<Record<Out>>> {
25        Ok(Vec::new())
26    }
27
28    /// Close the operator and release resources
29    async fn close(&mut self) -> StreamResult<()>;
30}