akka-streams
Akka Streams and Pekko Streams (Scala)
Quick start
- Think twice before using Streams: prefer plain functions, even for I/O.
- Test stream components using
TestSource,TestSink, andTestProbefromakka-stream-testkit. - Always define supervision strategies for error handling; default behavior tears down the entire stream.
- Read
references/akka-streams.mdfor core concepts and patterns. - Read
references/best-practices.mdfor critical guidance on when NOT to use streams. - Read
references/testing.mdfor comprehensive testing examples.
When NOT to use Streams
- Don't model plain data transformations as stream operators; use regular functions instead.
- Don't use streams for general I/O; prefer plain functions or other abstractions.
Workflow
- Verify that Streams are the right tool: do you need dataflow or reactive programming patterns?
- Design
Source,Flow, andSinkcomponents as separate, testable units. - Define error handling with
recover,recoverWithRetries, or supervision strategies. - Test each component with
TestSource/TestSinkorTestProbebefore integration. - Compose the final graph and materialize with explicit error handling.
Testing rules
- Write tests using
akka-stream-testkitfor custom stream components. - Use
TestSource.probeandTestSink.probefor fine-grained control over element flow. - Test backpressure behavior explicitly using
request()andexpectNoMessage(). - Test error scenarios with
expectError()or supervision strategies.
Pekko Streams
- Pekko Streams is a fork of Akka Streams with identical APIs (package names change from
akka.*toorg.apache.pekko.*). - All guidance for Akka Streams applies equally to Pekko Streams.
- When working with Pekko, adjust imports but keep patterns and testing approaches identical.
Output expectations
- Keep stream topologies simple and testable; break complex graphs into named components.
- Make error handling explicit via supervision or recovery operators.
- Prefer immutability; stream graphs are blueprints until materialized.
References
- Load
references/akka-streams.mdfor core concepts, operators, and materialization. - Load
references/best-practices.mdfor critical guidance on avoiding stream overuse. - Load
references/testing.mdfor testing patterns and complete examples.
More from alexandru/skills
cats-effect-io
Scala functional programming with Cats Effect IO and typeclasses. Use for wrapping side effects, modeling purity, choosing Sync/Async/Temporal/Concurrent, handling blocking I/O, and composing resources, fibers, and concurrency safely.
39cats-effect-resource
Scala resource lifecycle management with Cats Effect `Resource` and `IO`. Use when defining safe acquisition/release, composing resources (including parallel acquisition), or designing resource-safe APIs and cancellation behavior for files, streams, pools, clients, and background fibers.
36cats-mtl-typed-errors
Scala typed errors with Cats MTL Raise/Handle and allow/rescue. Use for designing custom domain error types without EitherT, while keeping Cats Effect and ecosystem composition. Covers Scala 2/3 syntax and IO-only or F[_] usage.
23arrow-typed-errors
Kotlin + Arrow typed error handling using Raise DSL and wrapper types (Either/Option/Ior/Result/nullable), including validation with accumulation, interop with exceptions, and custom error wrappers. Use for designing or refactoring error modeling, converting exception-based flows, building smart constructors, accumulating validation errors, or integrating Outcome/Progress-style wrappers with Arrow.
16kotlin-java-library
Kotlin design for Java libraries and Java consumers. Use when building Kotlin code intended for Java callers, aligning with Java interop, JVM annotations, records, and backward/binary compatibility rules.
14jspecify-nullness
JSpecify nullness annotations for Java APIs and tooling. Use when adopting or migrating JSpecify annotations, designing null-safe Java signatures and generics, or interpreting tool conformance and Kotlin interop.
13