+doc explain backpressure / reactive streams a bit

This commit is contained in:
Konrad 'ktoso' Malawski 2014-12-18 18:11:32 +01:00
parent 1c722b8ae1
commit 98143e3c93
4 changed files with 88 additions and 31 deletions

View file

@ -56,11 +56,8 @@ class FlowDocSpec extends AkkaSpec {
val source = Source(1 to 10)
val sink = Sink.fold[Int, Int](0)(_ + _)
// materialize the flow
val materialized: MaterializedMap = source.to(sink).run()
// get the materialized value from the running streams MaterializedMap
val sum: Future[Int] = materialized.get(sink)
// materialize the flow, getting the Sinks materialized value
val sum: Future[Int] = source.runWith(sink)
//#materialization-runWith
}

View file

@ -33,15 +33,13 @@ class FlowGraphDocSpec extends AkkaSpec {
val in = Source(1 to 10)
val out = Sink.ignore
val broadcast = Broadcast[Int]
val bcast = Broadcast[Int]
val merge = Merge[Int]
val f1 = Flow[Int].map(_ + 10)
val f3 = Flow[Int].map(_.toString)
val f2 = Flow[Int].map(_ + 20)
val f1, f2, f3, f4 = Flow[Int].map(_ + 10)
in ~> broadcast ~> f1 ~> merge
broadcast ~> f2 ~> merge ~> f3 ~> out
in ~> f1 ~> bcast ~> f2 ~> merge ~> f3 ~> out
bcast ~> f4 ~> merge
}
//#simple-flow-graph
//format: ON

View file

@ -51,7 +51,9 @@ class StreamPartialFlowGraphDocSpec extends AkkaSpec {
in3 ~> zip2.right
zip2.out ~> out
}
//#simple-partial-flow-graph
// format: ON
//#simple-partial-flow-graph
val resultSink = Sink.head[Int]