firehose

package module
v0.0.0-...-ccddb35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 10 Imported by: 0

README

Firehose

A type-safe event processing framework for Go. Build composable event pipelines with conditional execution, middleware support, and multiple naming conventions.

Choose the convention that fits your team — SQL, BDD (Given-When-Then), Kafka Streams, or MapReduce — all express the same pipeline.

Problem

Applications process events from various sources (HTTP requests, message queues, timers, system events, user input) and react with side effects. Without a structured approach, event handling becomes scattered across the codebase, difficult to test, hard to modify, and impossible to compose or reuse.

Solution

Firehose provides a declarative framework for event processing pipelines. Four rule types express the same pipeline — source → input condition → action → output condition → destination:

Stage SQLRule ScenarioRule (BDD) StreamRule (Kafka Streams) MapReduceRule
Source From When Source Source
Input condition Where Given Filter Filter
Action Select Then Map Map
Reduce — — — Reduce
Output condition Having GivenOutput FilterOutput FilterOutput
Destination Into To Sink Sink

SQLRule, ScenarioRule, and StreamRule share the same engine — they can be mixed freely in the same pipeline and use identical components for sources, conditions, actions, and destinations. MapReduceRule adds a Reduce stage for stateful accumulation across events.

rule := &fh.SQLRule[OrderEvent, Email]{
    ID:     "order_confirmation",
    Select: CreateEmail{},
    Into:   emailService,
    From:   orderSource,
    Where:  condition.Cond[OrderEvent](`amount > 100`),
    Having: condition.Cond[Email](`to != ""`),
}

Extend functionality with Middlewares that wrap callbacks, actions, and destinations.

Core Concepts

Events

Events are any Go type. No interface requirements. Optionally implement boolexpr.Symbols to expose attributes for condition evaluation:

type OrderPlaced struct {
    OrderID  string
    Amount   float64
    UserTier string
}

func (o OrderPlaced) Get(key string) (any, error) {
    switch key {
    case "amount":
        return o.Amount, nil
    case "tier":
        return o.UserTier, nil
    default:
        return nil, fmt.Errorf("unknown symbol: %s", key)
    }
}
Type-Safe Pipelines

Rules enforce type safety between pipeline stages. Input event type flows from source through transformation to destination:

// HTTP request events → Order events
SQLRule[HTTPRequest, OrderPlaced]

// Order events → Email notifications
SQLRule[OrderPlaced, EmailSent]

// Timer events → Timer events (identity transformation)
SQLRule[TimerTick, TimerTick]

The compiler ensures transformations match: Action[I, O] must accept the source's event type and produce the destination's event type.

Event Source Fanout

Register multiple rules with the same source instance. The framework detects this and starts the source only once, fanning events out to all rules that share it:

kafkaSource := &KafkaConsumer{Topic: "orders"}

// Both rules share kafkaSource - it starts once, events fan out
head, _ = Add(ctx, head, &SQLRule[OrderEvent, Email]{From: kafkaSource, ...})
head, _ = Add(ctx, head, &SQLRule[OrderEvent, Metrics]{From: kafkaSource, ...})

Different source instances (even of the same type) start independently.

Event Processing Middleware

Middlewares intercept and wrap three points in the pipeline: callbacks (event reception), actions (transformation), and destinations (output). Apply cross-cutting concerns like logging, metrics, retry logic, or rate limiting:

type LoggingMiddleware[I, O any] struct{}

type loggingAction[I, O any] struct {
    ruleID string
    next   Action[I, O]
}

func (a loggingAction[I, O]) Process(ctx context.Context, event I, syms boolexpr.Symbols) (O, error) {
    log.Printf("Processing event in rule %s", a.ruleID)
    out, err := a.next.Process(ctx, event, syms)
    log.Printf("Rule %s completed (err=%v)", a.ruleID, err)

    return out, err
}

func (m LoggingMiddleware[I, O]) WrapAction(
    _ context.Context,
    rule Rule,
    action Action[I, O],
) (Action[I, O], error) {
    return loggingAction[I, O]{ruleID: rule.GetID(), next: action}, nil
}

Middlewares compose in registration order (first middleware wraps later ones).

Error Handling

Rules never panic — they return typed errors that you classify with errors.As:

  • ConditionError — failure while evaluating Where/Given/Filter
  • ActionError — failure inside Action.Process
  • DestinationError — failure inside Destination.Send
  • ReduceError — failure inside Reducer.Reduce (MapReduceRule)

Conditions that evaluate to false are normal control flow, signalled by ErrInputNoMatch and ErrOutputNoMatch.

Each error is wrapped in a RuleError carrying the rule ID:

var ruleErr fh.RuleError
if errors.As(err, &ruleErr) {
    fmt.Printf("rule %s failed: %v", ruleErr.Rule, ruleErr.Err)
}

Features

  • ✅ Type-safe event pipelines - Generic types ensure compile-time correctness
  • ✅ Any Go type as event - No interface requirements, works with existing types
  • ✅ Declarative conditions - Boolean expressions via boolexpr library
  • ✅ Four naming conventions - SQL, BDD, Kafka Streams, and MapReduce
  • ✅ Unified middleware - Single interface for callbacks, transformations, destinations
  • ✅ Source fanout optimization - Shared sources start once, distribute to all rules
  • ✅ Context propagation - Full context.Context support for cancellation and values
  • ✅ Typed error classification - Structured error handling via errors.As
  • ✅ Struct validation - Declarative validation with go-playground/validator

Built-in Components

Firehose ships with reusable building blocks under subpackages.

Conditions (condition)
  • condition.Func[I](func(ctx, event, syms) (bool, error) { ... }) — function adapter for conditions
  • condition.Cond[I]("...") — expression-based filtering using boolexpr
  • &condition.RateLimit[I]{Limit: ..., Burst: ...} — throttle event processing
  • &condition.Once[I]{Duration: ..., Cache: ...} — deduplicate events by EventID
  • condition.Conditions[I]{...} — evaluate multiple conditions in sequence
Actions (actions)
  • actions.Func[I, O](func(ctx, event, syms) (O, error) { ... }) — function adapter for actions
  • &actions.Cache[I, O]{Action: ..., Cache: ..., TTL: ...} — memoize action output per event
  • actions.Chain[I, M, O]{...} — compose two actions (I -> M -> O)
  • actions.Chain3[I, A, B, O]{...} — compose three actions
  • actions.Chain4[I, A, B, C, O]{...} — compose four actions
  • actions.Chain5[I, A, B, C, D, O]{...} — compose five actions
  • &actions.RoundRobin[I, O]{Actions: ...} — dispatch events across actions in sequence
  • &actions.Random[I, O]{Actions: ...} — dispatch events to a random action
Destinations (destinations)
  • destinations.Func[T](func(ctx, event) error { ... }) — function adapter for destinations
  • &destinations.Accumulator[T]{} — accumulate output events in memory (Items() []T)
  • destinations.Fanout[T]{Destinations: ...} — send to all destinations
  • &destinations.RoundRobin[T]{Destinations: ...} — send in round-robin order
  • &destinations.Random[T]{Destinations: ...} — send to a random destination
  • destinations.FromChan[T]{Into: ...} — consume chan T, forward each item to Into
  • destinations.FromSlice[T]{Into: ...} — consume []T, forward each item to Into
  • destinations.ToChan[T]{Into: ...} — wrap T as one-item chan T, forward to Into
  • destinations.ToSlice[T]{Into: ...} — wrap T as one-item []T, forward to Into
Sources (sources)
  • sources.Func[T](func(ctx, cb) (<-chan struct{}, error) { ... }) — function adapter for sources
  • &sources.Manual[T]{} — manual source; call Emit(ctx, event) to trigger events
Cache Storage (cache)
  • cache.NewMemory[O](defaultTTL, cleanupInterval) — in-memory cache backend
Middlewares (middlewares)
  • &middlewares.Panic[I, O]{} — panic recovery for callback/action/destination
  • &middlewares.Slog[I, O]{} — structured event/logging via log/slog
  • &middlewares.Parallel[I, O]{Runner: runner.Basic{}} — run same-source rules in parallel

Environment-Specific Rules

Rules can be enabled only in selected environments:

rule := &fh.SQLRule[Event, Out]{
    ID:           "billing/charge",
    Environments: []string{"production", "staging"},
    Select:       action,
    Into:         destination,
    From:         source,
}

Add includes such a rule only when ENV matches one of Environments. If Environments is empty, the rule is always active.

Error Classification

Each rule execution returns an error to the source's error handler:

type ErrorHandler func(err error)

Common rule errors:

  • ErrInputNoMatch — input condition evaluated to false (normal control flow)
  • ErrOutputNoMatch — output condition evaluated to false (normal control flow)
  • ConditionError — failure while evaluating Where or Having
  • ActionError — failure inside Action.Process
  • DestinationError — failure inside Destination.Send
  • ReduceError — failure inside Reducer.Reduce

Use errors.Is / errors.As to classify errors in monitoring code.

Building Event Sources, Transformations, and Destinations

The framework defines three core interfaces you implement for custom event processing.

Event Sources

Sources produce events and send them to a callback function:

type Source[T any] interface {
    Start(ctx context.Context, cb Callback[T]) (done <-chan struct{}, err error)
}

Example - HTTP event source:

type HTTPSource struct {
    Addr string
}

func (s HTTPSource) Start(ctx context.Context, cb fh.Callback[HTTPRequest]) (<-chan struct{}, error) {
    server := &http.Server{Addr: s.Addr}

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        event := HTTPRequest{Method: r.Method, Path: r.URL.Path}

        cb(r.Context(), event, func(err error) {
            if err != nil {
                log.Printf("rule failed: %v", err)
            }
        })
    })

    go server.ListenAndServe()
    return ctx.Done(), nil
}
Event Transformations

Actions transform input events to output events:

type Action[I, O any] interface {
    Process(ctx context.Context, event I, syms boolexpr.Symbols) (O, error)
}

Example - Extract user data:

type ExtractUser struct{}

func (a ExtractUser) Process(
    ctx context.Context,
    req HTTPRequest,
    syms boolexpr.Symbols,
) (User, error) {
    userID := req.Headers.Get("X-User-ID")
    return fetchUser(userID), nil
}
Event Destinations

Destinations consume events and produce side effects:

type Destination[T any] interface {
    Send(ctx context.Context, event T) error
}

Example - Database writer:

type DBWriter struct {
    DB *sql.DB
}

func (d DBWriter) Send(ctx context.Context, user User) error {
    _, err := d.DB.ExecContext(ctx, "INSERT INTO users ...", user.ID, user.Name)
    return err
}

Quick Start

Process timer events during business hours:

package main

import (
    "context"
    "errors"
    "fmt"
    "log"
    "os"
    "os/signal"
    "time"

    "github.com/emad-elsaid/boolexpr"
    fh "github.com/emad-elsaid/firehose"
    "github.com/emad-elsaid/firehose/condition"
)

// 1. Define your event type
type Tick struct {
    Time time.Time
}

// 2. Make it conditionally evaluable (optional)
func (t Tick) Get(key string) (any, error) {
    if key == "hour" {
        return t.Time.Hour(), nil
    }
    return nil, fmt.Errorf("unknown symbol: %s", key)
}

// 3. Implement an event source
type Timer struct {
    Interval time.Duration
}

func (t Timer) Start(ctx context.Context, cb fh.Callback[Tick]) (<-chan struct{}, error) {
    go func() {
        ticker := time.NewTicker(t.Interval)
        defer ticker.Stop()
        for {
            select {
            case <-ctx.Done():
                return
            case now := <-ticker.C:
                cb(ctx, Tick{Time: now}, func(err error) {
                    if err != nil {
                        log.Printf("rule failed: %v", err)
                    }
                })
            }
        }
    }()
    return ctx.Done(), nil
}

// 4. Implement a transformation
type FormatTime struct{}

func (FormatTime) Process(ctx context.Context, t Tick, _ boolexpr.Symbols) (string, error) {
    return t.Time.Format("15:04:05"), nil
}

// 5. Implement a destination
type Printer struct{}

func (Printer) Send(ctx context.Context, msg string) error {
    println(msg)
    return nil
}

func main() {
    ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
    defer stop()

    // 6. Define a rule with a condition
    rule := &fh.SQLRule[Tick, string]{
        ID:     "print_business_hours",
        Select: FormatTime{},
        Into:   Printer{},
        Where:  condition.Cond[Tick]("hour >= 9 and hour < 17"),
        From:   Timer{Interval: 1 * time.Second},
    }

    // 7. Register and start
    head, _ := fh.Add(ctx, nil, rule)

    errHandler := func(err error) {
        if err != nil && !errors.Is(err, context.Canceled) {
            log.Printf("engine error: %v", err)
        }
    }

    doneChannels := fh.Start(ctx, head, errHandler)
    for _, ch := range doneChannels {
        <-ch
    }
}

Conditional Event Processing

Use condition.Cond to filter events based on their attributes. Events must implement boolexpr.Symbols interface:

type OrderEvent struct {
    Amount   float64
    Country  string
    Premium  bool
}

func (o OrderEvent) Get(key string) (any, error) {
    switch key {
    case "amount":
        return o.Amount, nil
    case "country":
        return o.Country, nil
    case "premium":
        return o.Premium, nil
    default:
        return nil, fmt.Errorf("unknown symbol: %s", key)
    }
}

// Only process high-value orders
Where: condition.Cond[OrderEvent]("amount > 1000")

// Geographic filtering
Where: condition.Cond[OrderEvent](`country = "US" or country = "CA"`)

// Complex conditions
Where: condition.Cond[OrderEvent]("premium = true and amount > 500")

Operators: =, ==, !=, <, <=, >, >=, contains, excludes, starts_with, ends_with

Logic: and, or, (...)

Types: Numbers, strings, booleans, slices

See boolexpr documentation for complete syntax.

API Reference

Core Types
// SQLRule defines a complete event processing pipeline
type SQLRule[I, O any] struct {
    ID           string             // Unique identifier
    Environments []string           // Active only when ENV matches; empty = all environments
    Select       Action[I, O]       // Event transformation
    Into         Destination[O]     // Output handler
    From         Source[I]          // Event source
    Where        Condition[I]       // Optional input condition
    Having       Condition[O]       // Optional output condition
    Middlewares  []Middleware[I, O] // Pipeline interceptors
}

// ScenarioRule is the BDD (Given-When-Then) variant
type ScenarioRule[I, O any] struct {
    ID           string
    Environments []string
    When         Source[I]        // Event source
    Given        Condition[I]     // Optional input condition
    Then         Action[I, O]     // Event transformation
    GivenOutput  Condition[O]     // Optional output condition
    To           Destination[O]   // Output handler
    Middlewares  []Middleware[I, O]
}

// StreamRule is the Kafka Streams variant
type StreamRule[I, O any] struct {
    ID           string
    Environments []string
    Source       Source[I]
    Filter       Condition[I]
    Map          Action[I, O]
    FilterOutput Condition[O]
    Sink         Destination[O]
    Middlewares  []Middleware[I, O]
}

// MapReduceRule adds a stateful Reduce stage (I -> M -> Out)
type MapReduceRule[I, M, Out any] struct {
    ID           string
    Environments []string
    Source       Source[I]
    Filter       Condition[I]
    Map          Action[I, M]
    Reduce       Reducer[M, Out]
    FilterOutput Condition[Out]
    Sink         Destination[Out]
    Middlewares  []Middleware[I, M]
}

// Source produces events
type Source[T any] interface {
    Start(ctx context.Context, cb Callback[T]) (done <-chan struct{}, err error)
}

// Callback receives source events and an error sink function
type Callback[I any] func(context.Context, I, ErrorHandler)

// ErrorHandler receives errors from rule execution
type ErrorHandler func(err error)

// Action transforms events
type Action[I, O any] interface {
    Process(ctx context.Context, event I, syms boolexpr.Symbols) (O, error)
}

// Destination consumes events
type Destination[T any] interface {
    Send(ctx context.Context, event T) error
}

// Condition filters events based on conditions
type Condition[I any] interface {
    Evaluate(ctx context.Context, event I, syms boolexpr.Symbols) (bool, error)
}

// Reducer combines an intermediary value with an accumulator
type Reducer[M, Out any] interface {
    Reduce(ctx context.Context, value M, accumulator Out) (Out, error)
}

// Middleware intercepts pipeline components
type Middleware[I, O any] interface {
    WrapCallback(ctx context.Context, rule Rule, callback Callback[I]) (Callback[I], error)
    WrapAction(ctx context.Context, rule Rule, action Action[I, O]) (Action[I, O], error)
    WrapDestination(ctx context.Context, rule Rule, destination Destination[O]) (Destination[O], error)
}

// RuleError wraps an error with the rule ID that produced it
type RuleError struct {
    Rule string
    Err  error
}
Core Functions
// Add registers one or more rules and returns the updated head
func Add(ctx context.Context, head Rule, rules ...Rule) (Rule, error)

// Start activates all registered event sources and returns done channels
func Start(ctx context.Context, head Rule, errFunc ErrorHandler) []<-chan struct{}
Event Symbol Interface

Events optionally implement this interface for conditional processing:

type Symbols interface {
    Get(key string) (any, error)
}

For convenience, you can embed boolexpr.SymbolsMap which implements this interface:

type MyEvent struct {
    boolexpr.SymbolsMap
}

event := MyEvent{
    SymbolsMap: boolexpr.SymbolsMap{
        "count": 42,
        "name":  "example",
    },
}

Design Principles

  • Event-first architecture - Everything revolves around event types and their flow
  • Minimal core concepts - Five interfaces: Source, Condition, Action, Destination, Middleware
  • Complete type safety - Generics ensure correctness from source to destination
  • Separation of concerns - Components define logic, rules define composition
  • Declarative over imperative - Describe event flows, not execution details
  • Reusability by default - Share sources, transformations, and destinations across rules
  • Convention flexibility - SQL, BDD, Kafka Streams, and MapReduce naming in one framework
  • Production-ready validation - Struct validation and extensive linting (50+ rules)

Use Cases

Event-Driven Microservices

  • HTTP request routing and handling
  • gRPC stream processing
  • WebSocket event distribution

Stream Processing

  • Message queue consumers (Kafka, RabbitMQ, NATS)
  • Real-time chat processing
  • Log aggregation and filtering

System Monitoring

  • Process lifecycle tracking
  • File system watching
  • Performance metric collection

Business Process Automation

  • Workflow orchestration
  • Rule-based decision engines
  • Event-driven ETL pipelines

Interactive Systems

  • Game input handling
  • UI event processing
  • Hardware device integration

License

See LICENSE file.

Documentation

Overview

Package firehose provides an event processing pipeline framework.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputNoMatch  = errors.New("no match")
	ErrOutputNoMatch = errors.New("output no match")
)

Sentinel errors used for control flow and classification.

Functions

func EventID

func EventID(event any) (uint64, error)

EventID computes a hash-based identifier for an event.

func EventSymbols

func EventSymbols(event any) boolexpr.Symbols

EventSymbols extracts symbols from an event if it implements boolexpr.Symbols. Events can embed boolexpr.Symbols directly to provide attribute access for condition evaluation. Returns a cached wrapper around the symbols for efficient repeated lookups. If the event doesn't implement boolexpr.Symbols, returns an empty SymbolsMap directly (no caching needed).

func NewRuleError

func NewRuleError(rule string, err error) error

NewRuleError creates an error with the given rule and underlying error.

func Start

func Start(ctx context.Context, head Rule, errFunc ErrorHandler) []<-chan struct{}

Start activates all registered rules and returns the done channels.

Types

type Action

type Action[I, O any] interface {
	Process(ctx context.Context, event I, syms boolexpr.Symbols) (O, error)
}

Action transforms input events to output events.

type ActionError

type ActionError struct{ Err error }

ActionError wraps an error returned by Action.Process.

func (ActionError) Error

func (e ActionError) Error() string

func (ActionError) Unwrap

func (e ActionError) Unwrap() error

type Callback

type Callback[I any] func(context.Context, I, ErrorHandler)

Callback is a function type that sources use to send events to the engine. It takes a context, an event, and a report sink callback.

type Condition

type Condition[I any] interface {
	Evaluate(ctx context.Context, event I, syms boolexpr.Symbols) (bool, error)
}

Condition evaluates whether an event should be processed by a rule. It receives the context, event, and symbols extracted from the event attributes, and returns true if the condition is met, false otherwise, along with any error.

type ConditionError

type ConditionError struct{ Err error }

ConditionError wraps an error that occurred during If evaluation.

func (ConditionError) Error

func (e ConditionError) Error() string

func (ConditionError) Unwrap

func (e ConditionError) Unwrap() error

type Destination

type Destination[T any] interface {
	Send(ctx context.Context, event T) error
}

Destination consumes events of type T.

type DestinationError

type DestinationError struct{ Err error }

DestinationError wraps an error returned by Destination.Send.

func (DestinationError) Error

func (e DestinationError) Error() string

func (DestinationError) Unwrap

func (e DestinationError) Unwrap() error

type ErrorHandler

type ErrorHandler func(err error)

ErrorHandler is a callback function type that handles errors occurring during event processing.

type MapReduceRule

type MapReduceRule[I, M, Out any] struct {
	// ID is a unique identifier for the rule.
	ID string `validate:"required"`
	// Environments is a list of environment names where the rule is active.
	Environments []string
	// Source is the source that produces events to be processed by this rule.
	Source Source[I] `validate:"required"`
	// Filter is a condition that must evaluate to true for the rule to process
	// the event.
	Filter Condition[I]
	// Map transforms input events into intermediary values.
	Map Action[I, M] `validate:"required"`
	// Reduce combines an intermediary value with the current accumulator to
	// produce a new output value.
	Reduce Reducer[M, Out] `validate:"required"`
	// FilterOutput is a condition that must evaluate to true for the rule to
	// send the reduced output to the Sink destination.
	FilterOutput Condition[Out]
	// Sink is the destination that consumes the reduced output.
	Sink Destination[Out] `validate:"required"`
	// Middlewares are applied to the callback and Map action. Middlewares wrap
	// in reverse order (first middleware wraps last). Note: middlewares only
	// wrap the callback and Map action — the Sink destination type (Out)
	// differs from the intermediary type (M), so destination wrapping is not
	// supported.
	Middlewares []Middleware[I, M]
	// contains filtered or unexported fields
}

MapReduceRule defines an event processing pipeline following the MapReduce pattern. I is the input event type, M is the intermediary type produced by Map, and Out is the accumulated output type.

Pipeline: Source → Filter → Map (I → M) → Reduce (M + Out → Out) →

FilterOutput → Sink.

func (*MapReduceRule[I, M, Out]) GetEnvironments

func (r *MapReduceRule[I, M, Out]) GetEnvironments() []string

GetEnvironments returns the list of environments where the rule is active.

func (*MapReduceRule[I, M, Out]) GetID

func (r *MapReduceRule[I, M, Out]) GetID() string

GetID returns the unique identifier of the rule.

func (*MapReduceRule[I, M, Out]) GetNext

func (r *MapReduceRule[I, M, Out]) GetNext() Rule

GetNext returns the next rule in the circular rule list.

func (*MapReduceRule[I, M, Out]) GetNextSameSource

func (r *MapReduceRule[I, M, Out]) GetNextSameSource() Rule

GetNextSameSource returns the next rule sharing the same source.

func (*MapReduceRule[I, M, Out]) GetPrev

func (r *MapReduceRule[I, M, Out]) GetPrev() Rule

GetPrev returns the previous rule in the circular rule list.

func (*MapReduceRule[I, M, Out]) GetPrevSameSource

func (r *MapReduceRule[I, M, Out]) GetPrevSameSource() Rule

GetPrevSameSource returns the previous rule sharing the same source.

func (*MapReduceRule[I, M, Out]) GetSource

func (r *MapReduceRule[I, M, Out]) GetSource() any

GetSource returns the source associated with this rule.

func (*MapReduceRule[I, M, Out]) Init

func (r *MapReduceRule[I, M, Out]) Init(ctx context.Context) error

Init initializes the rule by wrapping the callback and Map action with the configured middlewares. Middlewares are applied in reverse order.

func (*MapReduceRule[I, M, Out]) NextRunnable

func (r *MapReduceRule[I, M, Out]) NextRunnable() Runnable[I]

NextRunnable returns the next runnable rule with the same source.

func (*MapReduceRule[I, M, Out]) Run

func (r *MapReduceRule[I, M, Out]) Run(ctx context.Context, event I, syms boolexpr.Symbols) error

Run maps the input event to an intermediary value, reduces it with the current accumulator, then sends the result to the sink.

func (*MapReduceRule[I, M, Out]) SetNext

func (r *MapReduceRule[I, M, Out]) SetNext(n Rule)

SetNext sets the next rule in the circular rule list.

func (*MapReduceRule[I, M, Out]) SetNextSameSource

func (r *MapReduceRule[I, M, Out]) SetNextSameSource(n Rule)

SetNextSameSource sets the next rule sharing the same source.

func (*MapReduceRule[I, M, Out]) SetPrev

func (r *MapReduceRule[I, M, Out]) SetPrev(p Rule)

SetPrev sets the previous rule in the circular rule list.

func (*MapReduceRule[I, M, Out]) SetPrevSameSource

func (r *MapReduceRule[I, M, Out]) SetPrevSameSource(p Rule)

SetPrevSameSource sets the previous rule sharing the same source.

func (*MapReduceRule[I, M, Out]) Start

func (r *MapReduceRule[I, M, Out]) Start(ctx context.Context) (<-chan struct{}, error)

Start begins the source for this rule if it's the first rule with this source in the chain.

type Middleware

type Middleware[I, O any] interface {
	WrapCallback(ctx context.Context, rule Rule, callback Callback[I]) (Callback[I], error)
	WrapAction(ctx context.Context, rule Rule, action Action[I, O]) (Action[I, O], error)
	WrapDestination(ctx context.Context, rule Rule, destination Destination[O]) (Destination[O], error)
}

Middleware wraps callbacks, actions, and destinations to add cross-cutting concerns such as conditional execution, panic recovery, logging, retry logic, or telemetry.

type MockAction

type MockAction[I any, O any] struct {
	mock.Mock
}

MockAction is an autogenerated mock type for the Action type

func NewMockAction

func NewMockAction[I any, O any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockAction[I, O]

NewMockAction creates a new instance of MockAction. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockAction[I, O]) EXPECT

func (_m *MockAction[I, O]) EXPECT() *MockAction_Expecter[I, O]

func (*MockAction[I, O]) Process

func (_mock *MockAction[I, O]) Process(ctx context.Context, event I, syms boolexpr.Symbols) (O, error)

Process provides a mock function for the type MockAction

type MockAction_Expecter

type MockAction_Expecter[I any, O any] struct {
	// contains filtered or unexported fields
}

func (*MockAction_Expecter[I, O]) Process

func (_e *MockAction_Expecter[I, O]) Process(ctx any, event any, syms any) *MockAction_Process_Call[I, O]

Process is a helper method to define mock.On call

  • ctx context.Context
  • event I
  • syms boolexpr.Symbols

type MockAction_Process_Call

type MockAction_Process_Call[I any, O any] struct {
	*mock.Call
}

MockAction_Process_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Process'

func (*MockAction_Process_Call[I, O]) Return

func (_c *MockAction_Process_Call[I, O]) Return(v O, err error) *MockAction_Process_Call[I, O]

func (*MockAction_Process_Call[I, O]) Run

func (_c *MockAction_Process_Call[I, O]) Run(run func(ctx context.Context, event I, syms boolexpr.Symbols)) *MockAction_Process_Call[I, O]

func (*MockAction_Process_Call[I, O]) RunAndReturn

func (_c *MockAction_Process_Call[I, O]) RunAndReturn(run func(ctx context.Context, event I, syms boolexpr.Symbols) (O, error)) *MockAction_Process_Call[I, O]

type MockCondition

type MockCondition[I any] struct {
	mock.Mock
}

MockCondition is an autogenerated mock type for the Condition type

func NewMockCondition

func NewMockCondition[I any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockCondition[I]

NewMockCondition creates a new instance of MockCondition. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockCondition[I]) EXPECT

func (_m *MockCondition[I]) EXPECT() *MockCondition_Expecter[I]

func (*MockCondition[I]) Evaluate

func (_mock *MockCondition[I]) Evaluate(ctx context.Context, event I, syms boolexpr.Symbols) (bool, error)

Evaluate provides a mock function for the type MockCondition

type MockCondition_Evaluate_Call

type MockCondition_Evaluate_Call[I any] struct {
	*mock.Call
}

MockCondition_Evaluate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Evaluate'

func (*MockCondition_Evaluate_Call[I]) Return

func (*MockCondition_Evaluate_Call[I]) Run

func (_c *MockCondition_Evaluate_Call[I]) Run(run func(ctx context.Context, event I, syms boolexpr.Symbols)) *MockCondition_Evaluate_Call[I]

func (*MockCondition_Evaluate_Call[I]) RunAndReturn

func (_c *MockCondition_Evaluate_Call[I]) RunAndReturn(run func(ctx context.Context, event I, syms boolexpr.Symbols) (bool, error)) *MockCondition_Evaluate_Call[I]

type MockCondition_Expecter

type MockCondition_Expecter[I any] struct {
	// contains filtered or unexported fields
}

func (*MockCondition_Expecter[I]) Evaluate

func (_e *MockCondition_Expecter[I]) Evaluate(ctx any, event any, syms any) *MockCondition_Evaluate_Call[I]

Evaluate is a helper method to define mock.On call

  • ctx context.Context
  • event I
  • syms boolexpr.Symbols

type MockDestination

type MockDestination[T any] struct {
	mock.Mock
}

MockDestination is an autogenerated mock type for the Destination type

func NewMockDestination

func NewMockDestination[T any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDestination[T]

NewMockDestination creates a new instance of MockDestination. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockDestination[T]) EXPECT

func (_m *MockDestination[T]) EXPECT() *MockDestination_Expecter[T]

func (*MockDestination[T]) Send

func (_mock *MockDestination[T]) Send(ctx context.Context, event T) error

Send provides a mock function for the type MockDestination

type MockDestination_Expecter

type MockDestination_Expecter[T any] struct {
	// contains filtered or unexported fields
}

func (*MockDestination_Expecter[T]) Send

func (_e *MockDestination_Expecter[T]) Send(ctx any, event any) *MockDestination_Send_Call[T]

Send is a helper method to define mock.On call

  • ctx context.Context
  • event T

type MockDestination_Send_Call

type MockDestination_Send_Call[T any] struct {
	*mock.Call
}

MockDestination_Send_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Send'

func (*MockDestination_Send_Call[T]) Return

func (*MockDestination_Send_Call[T]) Run

func (_c *MockDestination_Send_Call[T]) Run(run func(ctx context.Context, event T)) *MockDestination_Send_Call[T]

func (*MockDestination_Send_Call[T]) RunAndReturn

func (_c *MockDestination_Send_Call[T]) RunAndReturn(run func(ctx context.Context, event T) error) *MockDestination_Send_Call[T]

type MockMiddleware

type MockMiddleware[I any, O any] struct {
	mock.Mock
}

MockMiddleware is an autogenerated mock type for the Middleware type

func NewMockMiddleware

func NewMockMiddleware[I any, O any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockMiddleware[I, O]

NewMockMiddleware creates a new instance of MockMiddleware. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockMiddleware[I, O]) EXPECT

func (_m *MockMiddleware[I, O]) EXPECT() *MockMiddleware_Expecter[I, O]

func (*MockMiddleware[I, O]) WrapAction

func (_mock *MockMiddleware[I, O]) WrapAction(ctx context.Context, rule Rule, action Action[I, O]) (Action[I, O], error)

WrapAction provides a mock function for the type MockMiddleware

func (*MockMiddleware[I, O]) WrapCallback

func (_mock *MockMiddleware[I, O]) WrapCallback(ctx context.Context, rule Rule, callback Callback[I]) (Callback[I], error)

WrapCallback provides a mock function for the type MockMiddleware

func (*MockMiddleware[I, O]) WrapDestination

func (_mock *MockMiddleware[I, O]) WrapDestination(ctx context.Context, rule Rule, destination Destination[O]) (Destination[O], error)

WrapDestination provides a mock function for the type MockMiddleware

type MockMiddleware_Expecter

type MockMiddleware_Expecter[I any, O any] struct {
	// contains filtered or unexported fields
}

func (*MockMiddleware_Expecter[I, O]) WrapAction

func (_e *MockMiddleware_Expecter[I, O]) WrapAction(ctx any, rule any, action any) *MockMiddleware_WrapAction_Call[I, O]

WrapAction is a helper method to define mock.On call

  • ctx context.Context
  • rule Rule
  • action Action[I, O]

func (*MockMiddleware_Expecter[I, O]) WrapCallback

func (_e *MockMiddleware_Expecter[I, O]) WrapCallback(ctx any, rule any, callback any) *MockMiddleware_WrapCallback_Call[I, O]

WrapCallback is a helper method to define mock.On call

  • ctx context.Context
  • rule Rule
  • callback Callback[I]

func (*MockMiddleware_Expecter[I, O]) WrapDestination

func (_e *MockMiddleware_Expecter[I, O]) WrapDestination(ctx any, rule any, destination any) *MockMiddleware_WrapDestination_Call[I, O]

WrapDestination is a helper method to define mock.On call

  • ctx context.Context
  • rule Rule
  • destination Destination[O]

type MockMiddleware_WrapAction_Call

type MockMiddleware_WrapAction_Call[I any, O any] struct {
	*mock.Call
}

MockMiddleware_WrapAction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WrapAction'

func (*MockMiddleware_WrapAction_Call[I, O]) Return

func (_c *MockMiddleware_WrapAction_Call[I, O]) Return(action1 Action[I, O], err error) *MockMiddleware_WrapAction_Call[I, O]

func (*MockMiddleware_WrapAction_Call[I, O]) Run

func (_c *MockMiddleware_WrapAction_Call[I, O]) Run(run func(ctx context.Context, rule Rule, action Action[I, O])) *MockMiddleware_WrapAction_Call[I, O]

func (*MockMiddleware_WrapAction_Call[I, O]) RunAndReturn

func (_c *MockMiddleware_WrapAction_Call[I, O]) RunAndReturn(run func(ctx context.Context, rule Rule, action Action[I, O]) (Action[I, O], error)) *MockMiddleware_WrapAction_Call[I, O]

type MockMiddleware_WrapCallback_Call

type MockMiddleware_WrapCallback_Call[I any, O any] struct {
	*mock.Call
}

MockMiddleware_WrapCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WrapCallback'

func (*MockMiddleware_WrapCallback_Call[I, O]) Return

func (_c *MockMiddleware_WrapCallback_Call[I, O]) Return(callback1 Callback[I], err error) *MockMiddleware_WrapCallback_Call[I, O]

func (*MockMiddleware_WrapCallback_Call[I, O]) Run

func (_c *MockMiddleware_WrapCallback_Call[I, O]) Run(run func(ctx context.Context, rule Rule, callback Callback[I])) *MockMiddleware_WrapCallback_Call[I, O]

func (*MockMiddleware_WrapCallback_Call[I, O]) RunAndReturn

func (_c *MockMiddleware_WrapCallback_Call[I, O]) RunAndReturn(run func(ctx context.Context, rule Rule, callback Callback[I]) (Callback[I], error)) *MockMiddleware_WrapCallback_Call[I, O]

type MockMiddleware_WrapDestination_Call

type MockMiddleware_WrapDestination_Call[I any, O any] struct {
	*mock.Call
}

MockMiddleware_WrapDestination_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WrapDestination'

func (*MockMiddleware_WrapDestination_Call[I, O]) Return

func (_c *MockMiddleware_WrapDestination_Call[I, O]) Return(destination1 Destination[O], err error) *MockMiddleware_WrapDestination_Call[I, O]

func (*MockMiddleware_WrapDestination_Call[I, O]) Run

func (_c *MockMiddleware_WrapDestination_Call[I, O]) Run(run func(ctx context.Context, rule Rule, destination Destination[O])) *MockMiddleware_WrapDestination_Call[I, O]

func (*MockMiddleware_WrapDestination_Call[I, O]) RunAndReturn

func (_c *MockMiddleware_WrapDestination_Call[I, O]) RunAndReturn(run func(ctx context.Context, rule Rule, destination Destination[O]) (Destination[O], error)) *MockMiddleware_WrapDestination_Call[I, O]

type MockReducer

type MockReducer[M any, Out any] struct {
	mock.Mock
}

MockReducer is an autogenerated mock type for the Reducer type

func NewMockReducer

func NewMockReducer[M any, Out any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockReducer[M, Out]

NewMockReducer creates a new instance of MockReducer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockReducer[M, Out]) EXPECT

func (_m *MockReducer[M, Out]) EXPECT() *MockReducer_Expecter[M, Out]

func (*MockReducer[M, Out]) Reduce

func (_mock *MockReducer[M, Out]) Reduce(ctx context.Context, intermediary M, accumulator Out) (Out, error)

Reduce provides a mock function for the type MockReducer

type MockReducer_Expecter

type MockReducer_Expecter[M any, Out any] struct {
	// contains filtered or unexported fields
}

func (*MockReducer_Expecter[M, Out]) Reduce

func (_e *MockReducer_Expecter[M, Out]) Reduce(ctx any, intermediary any, accumulator any) *MockReducer_Reduce_Call[M, Out]

Reduce is a helper method to define mock.On call

  • ctx context.Context
  • intermediary M
  • accumulator Out

type MockReducer_Reduce_Call

type MockReducer_Reduce_Call[M any, Out any] struct {
	*mock.Call
}

MockReducer_Reduce_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reduce'

func (*MockReducer_Reduce_Call[M, Out]) Return

func (_c *MockReducer_Reduce_Call[M, Out]) Return(v Out, err error) *MockReducer_Reduce_Call[M, Out]

func (*MockReducer_Reduce_Call[M, Out]) Run

func (_c *MockReducer_Reduce_Call[M, Out]) Run(run func(ctx context.Context, intermediary M, accumulator Out)) *MockReducer_Reduce_Call[M, Out]

func (*MockReducer_Reduce_Call[M, Out]) RunAndReturn

func (_c *MockReducer_Reduce_Call[M, Out]) RunAndReturn(run func(ctx context.Context, intermediary M, accumulator Out) (Out, error)) *MockReducer_Reduce_Call[M, Out]

type MockRule

type MockRule struct {
	mock.Mock
}

MockRule is an autogenerated mock type for the Rule type

func NewMockRule

func NewMockRule(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRule

NewMockRule creates a new instance of MockRule. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRule) EXPECT

func (_m *MockRule) EXPECT() *MockRule_Expecter

func (*MockRule) GetEnvironments

func (_mock *MockRule) GetEnvironments() []string

GetEnvironments provides a mock function for the type MockRule

func (*MockRule) GetID

func (_mock *MockRule) GetID() string

GetID provides a mock function for the type MockRule

func (*MockRule) GetNext

func (_mock *MockRule) GetNext() Rule

GetNext provides a mock function for the type MockRule

func (*MockRule) GetNextSameSource

func (_mock *MockRule) GetNextSameSource() Rule

GetNextSameSource provides a mock function for the type MockRule

func (*MockRule) GetPrev

func (_mock *MockRule) GetPrev() Rule

GetPrev provides a mock function for the type MockRule

func (*MockRule) GetSource

func (_mock *MockRule) GetSource() any

GetSource provides a mock function for the type MockRule

func (*MockRule) Init

func (_mock *MockRule) Init(ctx context.Context) error

Init provides a mock function for the type MockRule

func (*MockRule) SetNext

func (_mock *MockRule) SetNext(n Rule)

SetNext provides a mock function for the type MockRule

func (*MockRule) SetNextSameSource

func (_mock *MockRule) SetNextSameSource(n Rule)

SetNextSameSource provides a mock function for the type MockRule

func (*MockRule) SetPrev

func (_mock *MockRule) SetPrev(p Rule)

SetPrev provides a mock function for the type MockRule

func (*MockRule) SetPrevSameSource

func (_mock *MockRule) SetPrevSameSource(p Rule)

SetPrevSameSource provides a mock function for the type MockRule

func (*MockRule) Start

func (_mock *MockRule) Start(ctx context.Context) (<-chan struct{}, error)

Start provides a mock function for the type MockRule

type MockRule_Expecter

type MockRule_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockRule_Expecter) GetEnvironments

func (_e *MockRule_Expecter) GetEnvironments() *MockRule_GetEnvironments_Call

GetEnvironments is a helper method to define mock.On call

func (*MockRule_Expecter) GetID

GetID is a helper method to define mock.On call

func (*MockRule_Expecter) GetNext

GetNext is a helper method to define mock.On call

func (*MockRule_Expecter) GetNextSameSource

func (_e *MockRule_Expecter) GetNextSameSource() *MockRule_GetNextSameSource_Call

GetNextSameSource is a helper method to define mock.On call

func (*MockRule_Expecter) GetPrev

GetPrev is a helper method to define mock.On call

func (*MockRule_Expecter) GetSource

func (_e *MockRule_Expecter) GetSource() *MockRule_GetSource_Call

GetSource is a helper method to define mock.On call

func (*MockRule_Expecter) Init

func (_e *MockRule_Expecter) Init(ctx any) *MockRule_Init_Call

Init is a helper method to define mock.On call

  • ctx context.Context

func (*MockRule_Expecter) SetNext

SetNext is a helper method to define mock.On call

  • n Rule

func (*MockRule_Expecter) SetNextSameSource

func (_e *MockRule_Expecter) SetNextSameSource(n any) *MockRule_SetNextSameSource_Call

SetNextSameSource is a helper method to define mock.On call

  • n Rule

func (*MockRule_Expecter) SetPrev

SetPrev is a helper method to define mock.On call

  • p Rule

func (*MockRule_Expecter) SetPrevSameSource

func (_e *MockRule_Expecter) SetPrevSameSource(p any) *MockRule_SetPrevSameSource_Call

SetPrevSameSource is a helper method to define mock.On call

  • p Rule

func (*MockRule_Expecter) Start

func (_e *MockRule_Expecter) Start(ctx any) *MockRule_Start_Call

Start is a helper method to define mock.On call

  • ctx context.Context

type MockRule_GetEnvironments_Call

type MockRule_GetEnvironments_Call struct {
	*mock.Call
}

MockRule_GetEnvironments_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetEnvironments'

func (*MockRule_GetEnvironments_Call) Return

func (*MockRule_GetEnvironments_Call) Run

func (*MockRule_GetEnvironments_Call) RunAndReturn

func (_c *MockRule_GetEnvironments_Call) RunAndReturn(run func() []string) *MockRule_GetEnvironments_Call

type MockRule_GetID_Call

type MockRule_GetID_Call struct {
	*mock.Call
}

MockRule_GetID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetID'

func (*MockRule_GetID_Call) Return

func (*MockRule_GetID_Call) Run

func (_c *MockRule_GetID_Call) Run(run func()) *MockRule_GetID_Call

func (*MockRule_GetID_Call) RunAndReturn

func (_c *MockRule_GetID_Call) RunAndReturn(run func() string) *MockRule_GetID_Call

type MockRule_GetNextSameSource_Call

type MockRule_GetNextSameSource_Call struct {
	*mock.Call
}

MockRule_GetNextSameSource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNextSameSource'

func (*MockRule_GetNextSameSource_Call) Return

func (*MockRule_GetNextSameSource_Call) Run

func (*MockRule_GetNextSameSource_Call) RunAndReturn

type MockRule_GetNext_Call

type MockRule_GetNext_Call struct {
	*mock.Call
}

MockRule_GetNext_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNext'

func (*MockRule_GetNext_Call) Return

func (*MockRule_GetNext_Call) Run

func (_c *MockRule_GetNext_Call) Run(run func()) *MockRule_GetNext_Call

func (*MockRule_GetNext_Call) RunAndReturn

func (_c *MockRule_GetNext_Call) RunAndReturn(run func() Rule) *MockRule_GetNext_Call

type MockRule_GetPrev_Call

type MockRule_GetPrev_Call struct {
	*mock.Call
}

MockRule_GetPrev_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPrev'

func (*MockRule_GetPrev_Call) Return

func (*MockRule_GetPrev_Call) Run

func (_c *MockRule_GetPrev_Call) Run(run func()) *MockRule_GetPrev_Call

func (*MockRule_GetPrev_Call) RunAndReturn

func (_c *MockRule_GetPrev_Call) RunAndReturn(run func() Rule) *MockRule_GetPrev_Call

type MockRule_GetSource_Call

type MockRule_GetSource_Call struct {
	*mock.Call
}

MockRule_GetSource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSource'

func (*MockRule_GetSource_Call) Return

func (*MockRule_GetSource_Call) Run

func (_c *MockRule_GetSource_Call) Run(run func()) *MockRule_GetSource_Call

func (*MockRule_GetSource_Call) RunAndReturn

func (_c *MockRule_GetSource_Call) RunAndReturn(run func() any) *MockRule_GetSource_Call

type MockRule_Init_Call

type MockRule_Init_Call struct {
	*mock.Call
}

MockRule_Init_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Init'

func (*MockRule_Init_Call) Return

func (_c *MockRule_Init_Call) Return(err error) *MockRule_Init_Call

func (*MockRule_Init_Call) Run

func (_c *MockRule_Init_Call) Run(run func(ctx context.Context)) *MockRule_Init_Call

func (*MockRule_Init_Call) RunAndReturn

func (_c *MockRule_Init_Call) RunAndReturn(run func(ctx context.Context) error) *MockRule_Init_Call

type MockRule_SetNextSameSource_Call

type MockRule_SetNextSameSource_Call struct {
	*mock.Call
}

MockRule_SetNextSameSource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetNextSameSource'

func (*MockRule_SetNextSameSource_Call) Return

func (*MockRule_SetNextSameSource_Call) Run

func (*MockRule_SetNextSameSource_Call) RunAndReturn

type MockRule_SetNext_Call

type MockRule_SetNext_Call struct {
	*mock.Call
}

MockRule_SetNext_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetNext'

func (*MockRule_SetNext_Call) Return

func (*MockRule_SetNext_Call) Run

func (_c *MockRule_SetNext_Call) Run(run func(n Rule)) *MockRule_SetNext_Call

func (*MockRule_SetNext_Call) RunAndReturn

func (_c *MockRule_SetNext_Call) RunAndReturn(run func(n Rule)) *MockRule_SetNext_Call

type MockRule_SetPrevSameSource_Call

type MockRule_SetPrevSameSource_Call struct {
	*mock.Call
}

MockRule_SetPrevSameSource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPrevSameSource'

func (*MockRule_SetPrevSameSource_Call) Return

func (*MockRule_SetPrevSameSource_Call) Run

func (*MockRule_SetPrevSameSource_Call) RunAndReturn

type MockRule_SetPrev_Call

type MockRule_SetPrev_Call struct {
	*mock.Call
}

MockRule_SetPrev_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPrev'

func (*MockRule_SetPrev_Call) Return

func (*MockRule_SetPrev_Call) Run

func (_c *MockRule_SetPrev_Call) Run(run func(p Rule)) *MockRule_SetPrev_Call

func (*MockRule_SetPrev_Call) RunAndReturn

func (_c *MockRule_SetPrev_Call) RunAndReturn(run func(p Rule)) *MockRule_SetPrev_Call

type MockRule_Start_Call

type MockRule_Start_Call struct {
	*mock.Call
}

MockRule_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'

func (*MockRule_Start_Call) Return

func (_c *MockRule_Start_Call) Return(valCh <-chan struct{}, err error) *MockRule_Start_Call

func (*MockRule_Start_Call) Run

func (_c *MockRule_Start_Call) Run(run func(ctx context.Context)) *MockRule_Start_Call

func (*MockRule_Start_Call) RunAndReturn

func (_c *MockRule_Start_Call) RunAndReturn(run func(ctx context.Context) (<-chan struct{}, error)) *MockRule_Start_Call

type MockRunnable

type MockRunnable[I any] struct {
	mock.Mock
}

MockRunnable is an autogenerated mock type for the Runnable type

func NewMockRunnable

func NewMockRunnable[I any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRunnable[I]

NewMockRunnable creates a new instance of MockRunnable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRunnable[I]) EXPECT

func (_m *MockRunnable[I]) EXPECT() *MockRunnable_Expecter[I]

func (*MockRunnable[I]) NextRunnable

func (_mock *MockRunnable[I]) NextRunnable() Runnable[I]

NextRunnable provides a mock function for the type MockRunnable

func (*MockRunnable[I]) Run

func (_mock *MockRunnable[I]) Run(ctx context.Context, event I, syms boolexpr.Symbols) error

Run provides a mock function for the type MockRunnable

type MockRunnable_Expecter

type MockRunnable_Expecter[I any] struct {
	// contains filtered or unexported fields
}

func (*MockRunnable_Expecter[I]) NextRunnable

func (_e *MockRunnable_Expecter[I]) NextRunnable() *MockRunnable_NextRunnable_Call[I]

NextRunnable is a helper method to define mock.On call

func (*MockRunnable_Expecter[I]) Run

func (_e *MockRunnable_Expecter[I]) Run(ctx any, event any, syms any) *MockRunnable_Run_Call[I]

Run is a helper method to define mock.On call

  • ctx context.Context
  • event I
  • syms boolexpr.Symbols

type MockRunnable_NextRunnable_Call

type MockRunnable_NextRunnable_Call[I any] struct {
	*mock.Call
}

MockRunnable_NextRunnable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextRunnable'

func (*MockRunnable_NextRunnable_Call[I]) Return

func (*MockRunnable_NextRunnable_Call[I]) Run

func (*MockRunnable_NextRunnable_Call[I]) RunAndReturn

func (_c *MockRunnable_NextRunnable_Call[I]) RunAndReturn(run func() Runnable[I]) *MockRunnable_NextRunnable_Call[I]

type MockRunnable_Run_Call

type MockRunnable_Run_Call[I any] struct {
	*mock.Call
}

MockRunnable_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run'

func (*MockRunnable_Run_Call[I]) Return

func (_c *MockRunnable_Run_Call[I]) Return(err error) *MockRunnable_Run_Call[I]

func (*MockRunnable_Run_Call[I]) Run

func (_c *MockRunnable_Run_Call[I]) Run(run func(ctx context.Context, event I, syms boolexpr.Symbols)) *MockRunnable_Run_Call[I]

func (*MockRunnable_Run_Call[I]) RunAndReturn

func (_c *MockRunnable_Run_Call[I]) RunAndReturn(run func(ctx context.Context, event I, syms boolexpr.Symbols) error) *MockRunnable_Run_Call[I]

type MockSource

type MockSource[T any] struct {
	mock.Mock
}

MockSource is an autogenerated mock type for the Source type

func NewMockSource

func NewMockSource[T any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSource[T]

NewMockSource creates a new instance of MockSource. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSource[T]) EXPECT

func (_m *MockSource[T]) EXPECT() *MockSource_Expecter[T]

func (*MockSource[T]) Start

func (_mock *MockSource[T]) Start(ctx context.Context, cb Callback[T]) (<-chan struct{}, error)

Start provides a mock function for the type MockSource

type MockSource_Expecter

type MockSource_Expecter[T any] struct {
	// contains filtered or unexported fields
}

func (*MockSource_Expecter[T]) Start

func (_e *MockSource_Expecter[T]) Start(ctx any, cb any) *MockSource_Start_Call[T]

Start is a helper method to define mock.On call

  • ctx context.Context
  • cb Callback[T]

type MockSource_Start_Call

type MockSource_Start_Call[T any] struct {
	*mock.Call
}

MockSource_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'

func (*MockSource_Start_Call[T]) Return

func (_c *MockSource_Start_Call[T]) Return(done <-chan struct{}, err error) *MockSource_Start_Call[T]

func (*MockSource_Start_Call[T]) Run

func (_c *MockSource_Start_Call[T]) Run(run func(ctx context.Context, cb Callback[T])) *MockSource_Start_Call[T]

func (*MockSource_Start_Call[T]) RunAndReturn

func (_c *MockSource_Start_Call[T]) RunAndReturn(run func(ctx context.Context, cb Callback[T]) (<-chan struct{}, error)) *MockSource_Start_Call[T]

type ReduceError

type ReduceError struct{ Err error }

ReduceError wraps an error returned by Reducer.Reduce.

func (ReduceError) Error

func (e ReduceError) Error() string

func (ReduceError) Unwrap

func (e ReduceError) Unwrap() error

type Reducer

type Reducer[M, Out any] interface {
	Reduce(ctx context.Context, intermediary M, accumulator Out) (Out, error)
}

Reducer combines an intermediary value with an accumulator to produce a new output value. Used by MapReduceRule to reduce mapped events into a running result.

type Rule

type Rule interface {
	GetNext() Rule
	SetNext(n Rule)
	GetPrev() Rule
	SetPrev(p Rule)

	GetSource() any
	Start(ctx context.Context) (<-chan struct{}, error)

	SetNextSameSource(n Rule)
	SetPrevSameSource(p Rule)
	GetNextSameSource() Rule

	GetID() string
	GetEnvironments() []string
	Init(ctx context.Context) error
}

Rule handler that accumulates rules and manages their execution.

func Add

func Add(ctx context.Context, head Rule, rules ...Rule) (Rule, error)

Add registers one or more processing rules in the context.

type RuleError

type RuleError struct {
	Rule string
	Err  error
}

RuleError wraps an error with the rule ID that produced it.

func (RuleError) Error

func (e RuleError) Error() string

func (RuleError) Unwrap

func (e RuleError) Unwrap() error

type Runnable

type Runnable[I any] interface {
	Run(ctx context.Context, event I, syms boolexpr.Symbols) error
	NextRunnable() Runnable[I]
}

Runnable represents a rule that can be executed to process events.

type SQLRule

type SQLRule[I, O any] struct {
	// ID is a unique identifier for the rule, used for reporting and debugging purposes.
	ID string `validate:"required"`
	// Environments is a list of environment names where the rule is active. If
	// empty, the rule is active in all environments.
	Environments []string
	// Select is the action to process input events into output events.
	Select Action[I, O] `validate:"required"`
	// From is the source that produces events to be processed by this rule.
	From Source[I] `validate:"required"`
	// Where is a condition that must evaluate to true for the rule to process the event.
	// Use condition.Cond for string expressions, condition.RateLimit for rate limiting,
	// condition.Once for deduplication, or condition.Conditions for combining multiple conditions.
	Where Condition[I]
	// Having is a condition that must evaluate to true for the rule to send
	// the output of the Select action to the Into destination.
	Having Condition[O]
	// Into is the destination to send the output of the Select action.
	Into Destination[O] `validate:"required"`
	// Middlewares are the middlewares that will be applied to the action and
	// destination and callback of the rule. The first middleware wraps the
	// second middleware, and so on. The last middleware wraps the
	// actions/destination/callback of the rule.
	Middlewares []Middleware[I, O]
	// contains filtered or unexported fields
}

SQLRule defines an event processing pipeline from source to destination. I and O represent the input and output event types.

func (*SQLRule[I, O]) GetEnvironments

func (r *SQLRule[I, O]) GetEnvironments() []string

GetEnvironments returns the list of environments where the rule is active.

func (*SQLRule[I, O]) GetID

func (r *SQLRule[I, O]) GetID() string

GetID returns the unique identifier of the rule.

func (*SQLRule[I, O]) GetNext

func (r *SQLRule[I, O]) GetNext() Rule

GetNext returns the next rule in the circular rule list.

func (*SQLRule[I, O]) GetNextSameSource

func (r *SQLRule[I, O]) GetNextSameSource() Rule

GetNextSameSource returns the next rule sharing the same source.

func (*SQLRule[I, O]) GetPrev

func (r *SQLRule[I, O]) GetPrev() Rule

GetPrev returns the previous rule in the circular rule list.

func (*SQLRule[I, O]) GetSource

func (r *SQLRule[I, O]) GetSource() any

GetSource returns the source associated with this rule.

func (*SQLRule[I, O]) Init

func (r *SQLRule[I, O]) Init(ctx context.Context) error

Init initializes the rule by wrapping the callback, action, and destination with the configured middlewares. Middlewares are applied in reverse order, so the first middleware in the slice wraps all subsequent ones.

func (*SQLRule[I, O]) NextRunnable

func (r *SQLRule[I, O]) NextRunnable() Runnable[I]

NextRunnable returns the next runnable rule with the same source.

func (*SQLRule[I, O]) Run

func (r *SQLRule[I, O]) Run(ctx context.Context, event I, syms boolexpr.Symbols) error

Run executes the rule's action and destination for the given event.

func (*SQLRule[I, O]) SetNext

func (r *SQLRule[I, O]) SetNext(n Rule)

SetNext sets the next rule in the circular rule list.

func (*SQLRule[I, O]) SetNextSameSource

func (r *SQLRule[I, O]) SetNextSameSource(n Rule)

SetNextSameSource sets the next rule sharing the same source.

func (*SQLRule[I, O]) SetPrev

func (r *SQLRule[I, O]) SetPrev(p Rule)

SetPrev sets the previous rule in the circular rule list.

func (*SQLRule[I, O]) SetPrevSameSource

func (r *SQLRule[I, O]) SetPrevSameSource(p Rule)

SetPrevSameSource sets the previous rule sharing the same source.

func (*SQLRule[I, O]) Start

func (r *SQLRule[I, O]) Start(ctx context.Context) (<-chan struct{}, error)

Start begins the source for this rule if it's the first rule with this source in the chain. Returns a done channel when the source stops.

type ScenarioRule

type ScenarioRule[I, O any] struct {
	// ID is a unique identifier for the rule, used for reporting and
	// debugging purposes.
	ID string `validate:"required"`
	// Environments is a list of environment names where the rule is active.
	// If empty, the rule is active in all environments.
	Environments []string
	// When is the source that produces events to be processed by this rule.
	When Source[I] `validate:"required"`
	// Given is a condition that must evaluate to true for the rule to process
	// the event.
	Given Condition[I]
	// Then is the action to process input events into output events.
	Then Action[I, O] `validate:"required"`
	// GivenOutput is a condition that must evaluate to true for the rule to
	// send the output of the Then action to the To destination.
	GivenOutput Condition[O]
	// To is the destination to send the output of the Then action.
	To Destination[O] `validate:"required"`
	// Middlewares are the middlewares that will be applied to the action and
	// destination and callback of the rule. The first middleware wraps the
	// second middleware, and so on. The last middleware wraps the
	// actions/destination/callback of the rule.
	Middlewares []Middleware[I, O]
	// contains filtered or unexported fields
}

ScenarioRule defines an event processing pipeline following the BDD Given-When-Then pattern. I and O represent the input and output event types.

Pipeline: When (source) → Given (condition) → Then (action) →

GivenOutput (condition) → To (destination).

func (*ScenarioRule[I, O]) GetEnvironments

func (r *ScenarioRule[I, O]) GetEnvironments() []string

GetEnvironments returns the list of environments where the rule is active.

func (*ScenarioRule[I, O]) GetID

func (r *ScenarioRule[I, O]) GetID() string

GetID returns the unique identifier of the rule.

func (*ScenarioRule[I, O]) GetNext

func (r *ScenarioRule[I, O]) GetNext() Rule

GetNext returns the next rule in the circular rule list.

func (*ScenarioRule[I, O]) GetNextSameSource

func (r *ScenarioRule[I, O]) GetNextSameSource() Rule

GetNextSameSource returns the next rule sharing the same source.

func (*ScenarioRule[I, O]) GetPrev

func (r *ScenarioRule[I, O]) GetPrev() Rule

GetPrev returns the previous rule in the circular rule list.

func (*ScenarioRule[I, O]) GetPrevSameSource

func (r *ScenarioRule[I, O]) GetPrevSameSource() Rule

GetPrevSameSource returns the previous rule sharing the same source.

func (*ScenarioRule[I, O]) GetSource

func (r *ScenarioRule[I, O]) GetSource() any

GetSource returns the source associated with this rule.

func (*ScenarioRule[I, O]) Init

func (r *ScenarioRule[I, O]) Init(ctx context.Context) error

Init initializes the rule by wrapping the callback, action, and destination with the configured middlewares. Middlewares are applied in reverse order, so the first middleware in the slice wraps all subsequent ones.

func (*ScenarioRule[I, O]) NextRunnable

func (r *ScenarioRule[I, O]) NextRunnable() Runnable[I]

NextRunnable returns the next runnable rule with the same source.

func (*ScenarioRule[I, O]) Run

func (r *ScenarioRule[I, O]) Run(ctx context.Context, event I, syms boolexpr.Symbols) error

Run executes the rule's action and destination for the given event.

func (*ScenarioRule[I, O]) SetNext

func (r *ScenarioRule[I, O]) SetNext(n Rule)

SetNext sets the next rule in the circular rule list.

func (*ScenarioRule[I, O]) SetNextSameSource

func (r *ScenarioRule[I, O]) SetNextSameSource(n Rule)

SetNextSameSource sets the next rule sharing the same source.

func (*ScenarioRule[I, O]) SetPrev

func (r *ScenarioRule[I, O]) SetPrev(p Rule)

SetPrev sets the previous rule in the circular rule list.

func (*ScenarioRule[I, O]) SetPrevSameSource

func (r *ScenarioRule[I, O]) SetPrevSameSource(p Rule)

SetPrevSameSource sets the previous rule sharing the same source.

func (*ScenarioRule[I, O]) Start

func (r *ScenarioRule[I, O]) Start(ctx context.Context) (<-chan struct{}, error)

Start begins the source for this rule if it's the first rule with this source in the chain. Returns a done channel when the source stops.

type Source

type Source[T any] interface {
	Start(ctx context.Context, cb Callback[T]) (done <-chan struct{}, err error)
}

Source produces events of type T.

type StreamRule

type StreamRule[I, O any] struct {
	// ID is a unique identifier for the rule, used for reporting and
	// debugging purposes.
	ID string `validate:"required"`
	// Environments is a list of environment names where the rule is active.
	// If empty, the rule is active in all environments.
	Environments []string
	// Source is the source that produces events to be processed by this rule.
	Source Source[I] `validate:"required"`
	// Filter is a condition that must evaluate to true for the rule to process
	// the event.
	Filter Condition[I]
	// Map is the action to process input events into output events.
	Map Action[I, O] `validate:"required"`
	// FilterOutput is a condition that must evaluate to true for the rule to
	// send the output of the Map action to the Sink destination.
	FilterOutput Condition[O]
	// Sink is the destination to send the output of the Map action.
	Sink Destination[O] `validate:"required"`
	// Middlewares are the middlewares that will be applied to the action and
	// destination and callback of the rule. The first middleware wraps the
	// second middleware, and so on. The last middleware wraps the
	// actions/destination/callback of the rule.
	Middlewares []Middleware[I, O]
	// contains filtered or unexported fields
}

StreamRule defines an event processing pipeline following the Kafka Streams pattern. I and O represent the input and output event types.

Pipeline: Source → Filter → Map → FilterOutput → Sink.

func (*StreamRule[I, O]) GetEnvironments

func (r *StreamRule[I, O]) GetEnvironments() []string

GetEnvironments returns the list of environments where the rule is active.

func (*StreamRule[I, O]) GetID

func (r *StreamRule[I, O]) GetID() string

GetID returns the unique identifier of the rule.

func (*StreamRule[I, O]) GetNext

func (r *StreamRule[I, O]) GetNext() Rule

GetNext returns the next rule in the circular rule list.

func (*StreamRule[I, O]) GetNextSameSource

func (r *StreamRule[I, O]) GetNextSameSource() Rule

GetNextSameSource returns the next rule sharing the same source.

func (*StreamRule[I, O]) GetPrev

func (r *StreamRule[I, O]) GetPrev() Rule

GetPrev returns the previous rule in the circular rule list.

func (*StreamRule[I, O]) GetPrevSameSource

func (r *StreamRule[I, O]) GetPrevSameSource() Rule

GetPrevSameSource returns the previous rule sharing the same source.

func (*StreamRule[I, O]) GetSource

func (r *StreamRule[I, O]) GetSource() any

GetSource returns the source associated with this rule.

func (*StreamRule[I, O]) Init

func (r *StreamRule[I, O]) Init(ctx context.Context) error

Init initializes the rule by wrapping the callback, action, and destination with the configured middlewares. Middlewares are applied in reverse order, so the first middleware in the slice wraps all subsequent ones.

func (*StreamRule[I, O]) NextRunnable

func (r *StreamRule[I, O]) NextRunnable() Runnable[I]

NextRunnable returns the next runnable rule with the same source.

func (*StreamRule[I, O]) Run

func (r *StreamRule[I, O]) Run(ctx context.Context, event I, syms boolexpr.Symbols) error

Run executes the rule's action and destination for the given event.

func (*StreamRule[I, O]) SetNext

func (r *StreamRule[I, O]) SetNext(n Rule)

SetNext sets the next rule in the circular rule list.

func (*StreamRule[I, O]) SetNextSameSource

func (r *StreamRule[I, O]) SetNextSameSource(n Rule)

SetNextSameSource sets the next rule sharing the same source.

func (*StreamRule[I, O]) SetPrev

func (r *StreamRule[I, O]) SetPrev(p Rule)

SetPrev sets the previous rule in the circular rule list.

func (*StreamRule[I, O]) SetPrevSameSource

func (r *StreamRule[I, O]) SetPrevSameSource(p Rule)

SetPrevSameSource sets the previous rule sharing the same source.

func (*StreamRule[I, O]) Start

func (r *StreamRule[I, O]) Start(ctx context.Context) (<-chan struct{}, error)

Start begins the source for this rule if it's the first rule with this source in the chain. Returns a done channel when the source stops.

Directories

Path Synopsis
Package actions provides reusable action implementations for firehose rules.
Package actions provides reusable action implementations for firehose rules.
Package cache provides in-memory caching implementations for firehose middleware.
Package cache provides in-memory caching implementations for firehose middleware.
Package condition provides condition implementations for rule evaluation.
Package condition provides condition implementations for rule evaluation.
Package destinations provides reusable destination implementations for firehose rules.
Package destinations provides reusable destination implementations for firehose rules.
Package middlewares provides reusable firehose middleware implementations.
Package middlewares provides reusable firehose middleware implementations.
Package runner provides task runner implementations for executing functions concurrently.
Package runner provides task runner implementations for executing functions concurrently.
Package sources provides reusable source implementations for firehose rules.
Package sources provides reusable source implementations for firehose rules.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL