v0.5 · Go 1.27 Generic Methods · Zero Dependencies

Build bounded, type-safe data streams in Go

Fuse synchronous stages over iter.Seq2 with zero extra goroutines, compose resilient per-item steps, and control concurrency across any source and sink.

Get Started Browse Examples
$ go get github.com/vladimirvivien/automi
Illustration of a streaming pipeline flowing from sources through filters, parallel workers, and a timed batch collector into sinks

Sources emit lazy values into fused filters, bounded worker pools, and timed batch collectors before draining cleanly into sinks.

Concept illustration showing a source portal feeding items along a stream ribbon through a transform ring and filter sieve into a sink vessel

Source → Stream → Sink without channel churn

Calling FromCSV, Filter, and Map creates immutable pull iterators over iter.Seq2. Synchronous chains execute inline on a single loop with zero background goroutines until an async boundary is needed.

err := automi.FromCSV(file, automi.SkipHeader()).
    Filter(func(r []string) bool { return len(r) == 3 }).
    Map(toNormalizedRow).
    Into(ctx, automi.ToCSV(outWriter))
Read Execution Model → Explore Sources →
Concept illustration of three linked processing steps featuring retry backoff, a circuit breaker shield gate, and a dead-letter side chute for failed items

Wrap retries, breakers, and DLQs in reusable Steps

Do, Then, and Chain compose fallible transforms cleanly. Attach Retry, CircuitBreaker, and typed OnError dead-letter routing once, then run sequentially via TryMap or concurrently via ParMap.

enrich := automi.Do(fetchAccount).
    Retry(3, 25*time.Millisecond, automi.Jitter(0.2)).
    CircuitBreaker(5, 15*time.Second).
    OnError(recordDeadLetter).
    Then(automi.Chain(validateOrder, applyDiscount))
Explore Steps & Resilience → See Enrichment Example →
Concept illustration of one stream splitting across four parallel worker lanes before converging into a timed batch tray releasing grouped packets

Bound workers, keep order, and flush on size or timer

ParMap and ParEach cap concurrent goroutines cleanly, recover panics into errors, and fall back inline with zero goroutines when configured with a single worker. Pair with Batch to flush full slices or partial windows after idle intervals.

ready := automi.FromLines(logs).
    ParMap(enrich, automi.Workers(8), automi.Ordered())

err := automi.Batch(ready, automi.MaxSize(64), automi.MaxWait(200*time.Millisecond)).
    Into(ctx, automi.ToFunc(bulkWrite))
Explore Concurrency → Explore Flow Control →

Complete, Runnable Examples

Four self-contained Go programs showcasing end-to-end streaming patterns.

View All Examples →
err := automi.FromCSV(strings.NewReader(csvData), automi.SkipHeader()).
    ParMap(enrichStep, automi.Workers(4), automi.Ordered()).
    Map(orderToCSVRow).
    Into(ctx, automi.ToCSV(&out))
CSV ingestion, exponential retry, circuit breaker, typed DLQ capture, and ordered workers. Read Full Program →
alertLogs := automi.Merge(automi.FromChan(east), automi.FromChan(west)).
    BufferDrop(32, countDrop, automi.DropOldest()).
    TryMap(parseAlertEntry).
    RateLimit(200, automi.Burst(8))

err := automi.Batch(alertLogs, automi.MaxSize(2), automi.MaxWait(50*time.Millisecond)).
    Into(ctx, automi.ToFunc(flushAlertBatch))
Concurrent stream fan-in, ring-buffered burst shedding, token-bucket pacing, and timed batching. Read Full Program →
formatted := automi.FromChan(rawStates).
    Debounce(35*time.Millisecond).
    Map(formatAlertLine)

err := automi.FanOut(ctx, formatted,
    automi.ToWriter[string](&auditLog),
    automi.ToChan(alertCh, automi.CloseOnDone()),
)
Debounced status updates broadcast concurrently to an audit writer and a ParEach webhook dispatcher. Read Full Program →
discrepancies, err := automi.Zip(automi.FromSlice(invoices), automi.FromSeq(settlements)).
    TryMap(compareInvoicePair).
    GroupBy(ctx, func(d Discrepancy) string { return d.Region })
Lockstep stream pairing with Zip, line-item expansion via FlatMap, GroupBy, and Reduce. Read Full Program →

Explore the Documentation

Jump straight to guides, component manuals, runnable programs, or signature tables.