FlowGo is a type-safe, reactive stream framework for Go, built with modern concepts from functional programming, algebraic effects, stream processing, and system-level concurrency.
It aims to solve:
- complex data pipelines in Go
- concurrency with cancellation and error handling
- real-time stream control (not just batch-style Rx)
A composable, lazy, context-aware pipeline of typed values. Supports:
Map,Filter,FlatMap,Tap,ForEach- contextual cancellation
- effect propagation and routing
Flow steps can raise side-effects (errors, retries, logs, timeouts) using:
RaiseEffect(effectType string, data any)
HandleEffect(effectType string, handler func(EffectContext) error)Inspired by algebraic effects and effect handlers.
FlowCtx carries context (cancel, deadline, values) + trace metadata:
type FlowCtx interface {
Context() context.Context
DeadlineExceeded() bool
WithValue(key, val any) FlowCtx
}Flow branching based on type rather than string-based conditionals.
flow.
SwitchTyped().
Case(func(x MyTypeA) { ... }).
Case(func(x MyTypeB) { ... }).
Default(func(x any) { ... })Parallelism with backpressure and graceful shutdown.
flow.WithWorkerPool(size int)type FlowSource[T any] interface {
Start(ctx context.Context, out chan<- T) error
}type FlowSink[T any] interface {
Write(ctx context.Context, item T) error
}Bidirectional streaming interface (gRPC, WebSockets)
type FlowDuplex[In any, Out any] interface {
Open(ctx context.Context, in <-chan In, out chan<- Out) error
}| Interface | Purpose |
|---|---|
FlowMiddleware |
Wrap steps with logging/tracing |
FlowHook |
Lifecycle hooks |
FlowInspector |
Describe(), trace, debug info |
FlowConfigurable |
Live config reload |
FlowCheckpointable |
Save/restore runtime state |
FlowValidator |
Startup validation |
- Lazy, context-aware flows
- Type-safe chaining
- Centralized effect handling
- Throttle, debounce, delay
- Typed branching (SwitchTyped, UnionMatch)
- Integrated context.Context
- Retry, timeout, rate control
- Kafka / Redis / HTTP integration
- OpenTelemetry-compatible tracing
- Stateful ops:
Scan,Reduce,GroupBy - Windowed ops:
Windowed,BatchMap - Undo logic:
MapWithUndo - Timed schedulers:
Schedule,DelayUntil - Effect plugins:
RegisterEffectHandler - Validation DSL:
.Validate() - Sync ops:
.Join(),.Barrier() - Buffered flow:
.WithBuffer(strategy) - Duplex stream:
DuplexFlow[In, Out] - Sharding:
.ShardBy().WorkerPoolPerShard() - Resource-safe steps:
.WithResource().Use() - Live reload config:
.OnConfigChange() - TestKit:
Push(),Expect(),Simulate()
Flow[T]Map,Filter,FlatMap,TapFlowCtx,EffectFromChannel,RunSwitchTyped,UnionMatch
.Scan,.GroupBy,.Windowed.Schedule,.DelayUntil.MapWithUndo,.RetryPolicy,.ShardBy
.Expect().ThenWithin()(temporal logic).DescribeJSON()(final tagless).Trace().Explain()(provenance tracking).Backward()(differentiable flows)
- Internal executor / scheduler (per-flow)
- Safe shutdown and cancellation
- Buffering and backpressure
- Hook points and metrics
- DSL + introspection (
Describe(),Graph())
TestKit.Push()— inject dataTestKit.Expect()— assert resultsTestKit.Log()— trace internal flow- Simulate deterministic runs with no goroutines
- Core API
- Filters, map, flatMap, tap, forEach
- WorkerPool, Retry
- FlowCtx + Effects
- Kafka + Redis sources
- Join, Barrier, Undo
- OpenTelemetry integration
- TestKit + DevTools
- Visual editor (inspired by Temporal UI)