Build composable event pipelines with conditional execution and middleware support. Event-driven architecture that the compiler can verify. Choose the naming convention that fits your team: SQL, BDD, Kafka Streams, or MapReduce.
type SQLRule[I, O any] struct {
ID string // Unique ID
Select Action[I, O] // Transform
Into Destination[O] // Output
From Source[I] // Event source
Where Condition[I] // Input condition
Having Condition[O] // Output condition
} One pipeline, four naming conventions: SQL, BDD (Given-When-Then), Kafka Streams, or MapReduce.
Event handling scattered across codebases. Difficult to test, hard to modify, impossible to compose. Side effects mixed with business logic. No reusability.
Declarative event pipelines with type safety. Composable components. Middleware for cross-cutting concerns.
Generic types ensure compile-time correctness from source to destination. The compiler verifies your event flows.
Any Go type works as an event. No interface requirements. Works seamlessly with existing types.
Boolean expressions for event filtering. Rich operators for numbers, strings, and collections.
Single interface for callbacks, transformations, and destinations. Composable cross-cutting concerns.
Shared sources start once and distribute events to all registered rules automatically.
go get github.com/emad-elsaid/firehosepackage main
import (
"context"
"fmt"
"time"
fh "github.com/emad-elsaid/firehose"
"github.com/emad-elsaid/firehose/condition"
)
type Tick struct {
Time time.Time
}
func (t Tick) Get(key string) (any, error) {
if key == "hour" {
return t.Time.Hour(), nil
}
return nil, fmt.Errorf("unknown: %s", key)
}
func main() {
ctx := context.Background()
rule := &fh.SQLRule[Tick, string]{
ID: "business_hours",
Select: FormatTime{},
Into: Printer{},
From: Timer{Interval: 1 * time.Second},
Where: condition.Cond[Tick]("hour >= 9 and hour < 17"),
}
head, _ := fh.Add(ctx, nil, rule)
doneChannels := fh.Start(ctx, head, nil)
for _, ch := range doneChannels {
<-ch
}
}Produces events of a specific type. HTTP servers, message queues, timers, file watchers.
type Source[T any] interfaceOptional filter evaluated against event attributes. Boolean expressions or custom logic.
type Condition[I any] interfaceConverts input events to output events. Business logic, enrichment, validation.
type Action[I, O any] interfaceHandles output events. Database writes, API calls, message publishing, logging.
type Destination[T any] interfaceHTTP routing, gRPC streams, WebSocket distribution
Kafka consumers, real-time chat, log aggregation
Process tracking, file watching, metric collection
Workflow orchestration, rule engines, ETL pipelines
Game input, UI events, hardware integration
CQRS, event sourcing, saga patterns
Start building composable, testable event processing systems in Go