The Akka Streams docs (Basics and working with Flows • Akka Documentation) mention that Source
s can be reused (i.e., materialized multiple times), but I’ve seen cases where this doesn’t work — for example:
Source.fromIterator(() => it)
fails if the same iterator is reused.
val ii = Iterator(1L, 5L)
val a = Source.fromIterator(() => ii.iterator)
println("------")
await(a.runWith(Sink.foreach(println)))
println("------")
await(a.runWith(Sink.foreach(println)))
println("------")
Output:
------
1
5
------
------
- In Akka HTTP,
response.entity.dataBytes
can’t be consumed more than once. There would an exeption thrown that Substream cannot be materialzed multiple times.
Is the documentation inaccurate, or is there some nuance I’m missing?
Regards,
Kyrylo