StreamForge is a declarative DSL for building reactive stream processing pipelines with rich temporal operators. It's embedded in Kotlin (for ergonomics and JVM interoperability) but compiles to a portable execution graph. Inspired by Akka Streams, Flink, and Timely Dataflow, it emphasizes time-aware processing, compile-time optimizations, async scheduling, reactive backpressure, and observability.
Core Syntax
Streams are defined as pipelines chaining operators on Source<T>, Flow<T,R>, and Sink<R>. Temporal operators handle time explicitly via Duration (e.g., 1.seconds, 10.minutes).
Key Temporal Operators
kotlin
import streamforge.*
val input: Source<Event> = sourceFromKafka("events")
val processed = input
.window(Tumble, 5.minutes) // Fixed tumbling windows
.aggregate { events -> events.sumBy { it.value } }
.window(Slide, size = 10.minutes, slide = 1.minute) // Sliding windows
.join(other = userStream, on = { e, u -> e.userId == u.id }, within = 30.seconds)
.delay(2.seconds) // Emit after delay
.session(gap = 1.minute) // Group into sessions
.timeout(15.minutes) // Fail if no events in window
. watermark(allowedLag = 1.minute) // Handle late events
Window Types:
Type
Params
Semantics
Tumble
size: Duration
Non-overlapping fixed windows.
Slide
size: Duration, slide: Duration
Overlapping windows.
Session
gap: Duration
Dynamic windows closing on inactivity.
Time Handling:
delay(duration): Buffers and emits after time.
timeout(duration): Errors or drops if no data.
join(other: Source, on: (T,U)->Boolean, within: Duration): Temporal inner join.
watermark(allowedLag: Duration): Advances processing time, drops late data.
This design balances expressiveness, performance, and usability. Temporal ops ensure correct time handling; the pipeline guarantees efficiency. Open to extensions like ML ops or SQL integration! Questions?