liveBook · Manning

Flow

As explained in Akka in Action, Second Edition

The Flow API is the Akka Streams API for constructing linear pipelines that transform elements between sources and sinks.

A Flow is the transformation stage in an Akka Streams pipeline. It accepts elements from an upstream Source, transforms them, and passes the results to a downstream Sink. section 10.1.1 section 16.0

A linear stream combines three stages:

Filtering a finite stream

A processor can retain only even integers: `val processor: Flow[Int, Int, NotUsed] = Flow[Int].filter(_ % 2 == 0)`. Connect it with `producer.via(processor).toMat(consumer)(Keep.right)` and run the resulting blueprint. With a source containing `List(1, 2, 3)` and a sink writing to a fake database, only `2` is stored. section 10.1.2 section 10.1.4 section 10.1.7

The type `Flow[Int, Int, NotUsed]` declares integer input, integer output, and an unused materialized value. Flows can serve finite or infinite streams; the API remains the same. section 10.1.2 section 10.1.4

val processor: Flow[Int, Int, NotUsed] = Flow[Int].filter(_ % 2 == 0)

The typed filtering processor makes the Flow’s input, output, and transformation explicit. section 10.1.4

How Akka in Action, Second Edition covers it

How deep it goes
Explains stage roles, typed signatures, filtering, connection, and materialization, while deferring branching to GraphDSL and low-level composition to GraphStage API.
Examples
Demonstrates even-number filtering from a List source into a fake database and shows a typed filtering processor.
What it assumes
Introduces Source, Flow, and Sink together through a finite stream before applying the same API to infinite streams.
What you can do after
Builds from scratch a typed filtering stage and connects it into a runnable source-to-sink pipeline.
How it connects
Connects Flow with Source, Sink, materialization, Akka Streams, persistence queries, projections, GraphDSL, and GraphStage API.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.