samber-ro

Build type-safe reactive stream pipelines in Go using samber/ro operators and subjects.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill samber-ro-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: samber-ro
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/samber/samber-ro
Command: npx skills add https://github.com/asarchami/dotfiles --skill samber-ro-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling asynchronous, infinite, or multi-source data in Go with raw goroutines and channels leads to unbounded streams, silent error loss, and tangled concurrency code. This Skill guides you to compose declarative, type-safe reactive pipelines with samber/ro so every stream is bounded, every error is observed, and every operator chain is compile-time checked. ## Core Features & Use Cases - Typed Pipeline Composition: Chain 150+ operators (Map, FlatMap, Filter, Merge, Zip, Retry, Timeout) via Pipe2–Pipe25 for compile-time type safety across transformations. - Cold vs Hot Stream Guidance: Choose between cold observables, Share/ShareReplay, Connectable, and five subject types (Publish, Behavior, Replay, Async, Unicast) based on whether sources are expensive or events must be shared. - Production Patterns: Apply ready-made patterns for retry with exponential backoff, WebSocket fan-out, graceful shutdown via OS signals, error recovery cascades, and running aggregations. - Plugin Ecosystem: Extend pipelines with 40+ plugins for HTTP, fsnotify, cron, JSON/CSV encoding, slog/zap logging, and rate limiting. - Use Case: You need to consume a WebSocket ticker stream, share it across a dashboard updater, a metrics recorder, and a price-alert filter, with debounce and graceful SIGTERM shutdown — this Skill walks you through Share, Filter, ThrottleTime, and TakeUntil to build it correctly. ## Quick Start Ask the AI to build a samber/ro pipeline that fetches data from an HTTP endpoint with retry, timeout, and a cached fallback, then collects the result synchronously.

Frequently Asked Questions about samber-ro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a reactive stream pipeline in Go with samber/ro?

Create an observable with a creation operator like Just, FromChannel, or Interval, then chain operators using typed Pipe2 through Pipe25 functions, and finally Subscribe with an observer. Use ro.Collect to block a finite stream and receive ([]T, error) synchronously.

When should I use samber/ro vs samber/lo in Go?

Use samber/lo for finite slice transforms like Map, Filter, and Reduce on in-memory collections. Use samber/ro only when data arrives over time, comes from multiple sources, is infinite, or needs retry, timeout, and backpressure handling.

What is the difference between cold and hot observables in samber/ro?

Cold observables start an independent execution for each subscriber and are the default choice. Hot observables share one execution across subscribers via Share, ShareReplay, Connectable, or Subjects, and suit expensive sources like WebSockets or database polls.

How do I handle errors in a samber/ro stream?

Always subscribe with ro.NewObserver providing onNext, onError, and onComplete callbacks, since an unhandled error means silent data loss. In the pipeline, use Retry or RetryWithConfig for transient failures, Catch for fallback sources, and OnErrorReturn for default values.

How do I stop an infinite observable stream in Go?

Bound every infinite stream with Take(n), TakeUntil(signal), Timeout(d), or context cancellation via ContextWithTimeout and ThrowOnContextCancel. The signal plugin provides an observable emitting on SIGTERM/SIGINT for graceful shutdown with TakeUntil.

Which samber/ro subject type should I use for late subscribers?

Use BehaviorSubject to replay the last value to new subscribers, ReplaySubject to replay the last N buffered values, or AsyncSubject to emit only the final value on completion. PublishSubject gives late subscribers only future emissions.