Expand description
pulse-core: Fundamental types, traits and a basic executor.
Goal: provide the essential abstractions for a streaming pipeline:
- Record, EventTime, Watermark
- Traits: Source, Operator, Sink, Context, KvState, Timers
- Simple tokio-based executor
Quick example:
use async_trait::async_trait;
use pulse_core::prelude::*;
struct MySource;
#[async_trait]
impl Source for MySource {
async fn run(&mut self, ctx: &mut dyn Context) -> Result<()> {
ctx.collect(Record::from_value("hello"));
Ok(())
}
}
struct MyOp;
#[async_trait]
impl Operator for MyOp {
async fn on_element(&mut self, ctx: &mut dyn Context, rec: Record) -> Result<()> {
// pass-through
ctx.collect(rec);
Ok(())
}
}
struct MySink;
#[async_trait]
impl Sink for MySink {
async fn on_element(&mut self, rec: Record) -> Result<()> {
println!("{}", rec.value);
Ok(())
}
}
#[tokio::main]
async fn main() -> Result<()> {
let mut exec = Executor::new();
exec.source(MySource).operator(MyOp).sink(MySink);
exec.run().await?;
Ok(())
}Re-exports§
pub use checkpoint::CheckpointMeta;pub use checkpoint::SnapshotId;pub use record::Record;
Modules§
Structs§
- Event
Time - Logical event-time as wall-clock timestamp in UTC.
Use
EventTime::nowfor current time. - Executor
- A tiny, single-pipeline executor. Wires: Source -> Operators -> Sink. Drives watermarks and event-time timers.
- Simple
InMemory State - Simple
Timers - Minimal in-memory timer service used by the demo executor.
- Watermark
- A low-watermark indicating no future records <= this event-time are expected.
Enums§
Traits§
- Context
- Execution context visible to Sources and Operators.
- KvState
- Key-Value state abstraction for stateful operators.
- Operator
- Core operator interface. Override
on_watermark/on_timerif needed. - Sink
- A terminal sink that receives records (and optional watermarks).
- Source
- A data source that pushes records into the pipeline.
- Timers
- Timer service for event-time callbacks requested by operators.