Crate pulse_core

Crate pulse_core 

Source
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§

checkpoint
config
metrics
prelude
record

Structs§

EventTime
Logical event-time as wall-clock timestamp in UTC. Use EventTime::now for current time.
Executor
A tiny, single-pipeline executor. Wires: Source -> Operators -> Sink. Drives watermarks and event-time timers.
SimpleInMemoryState
SimpleTimers
Minimal in-memory timer service used by the demo executor.
Watermark
A low-watermark indicating no future records <= this event-time are expected.

Enums§

Error

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_timer if 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.

Type Aliases§

Result