Scala reactive streaming with Akka Streams and Pekko Streams. Use for dataflow and reactive programming patterns, testing stream components, and understanding when NOT to use streams (prefer plain functions for transformations and I/O).
Resources
1Install
npx skillscat add alexandru/skills/akka-streams Install via the SkillsCat registry.
SKILL.md
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.