!str #18692 javadsl.FlowGraph.Builder.add()

* also make factories more consistent by only offering
  FlowGraph.create()
* also remove secondary (edge-based) FlowGraph.Builder DSL
* also improve naming for conversions from Graph to
  Source/Flow/BidiFlow/Sink
This commit is contained in:
Viktor Klang 2015-10-21 22:45:39 +02:00 committed by Roland Kuhn
parent 0f99a42df9
commit f29d7affbd
120 changed files with 1535 additions and 1897 deletions

View file

@ -1,6 +1,6 @@
package docs.stream
import akka.stream.{ OverflowStrategy, ActorMaterializer }
import akka.stream.{ ClosedShape, OverflowStrategy, ActorMaterializer }
import akka.stream.scaladsl._
import akka.stream.testkit.AkkaSpec
@ -16,7 +16,7 @@ class GraphCyclesSpec extends AkkaSpec {
// format: OFF
//#deadlocked
// WARNING! The graph below deadlocks!
FlowGraph.closed() { implicit b =>
RunnableGraph.fromGraph(FlowGraph.create() { implicit b =>
import FlowGraph.Implicits._
val merge = b.add(Merge[Int](2))
@ -24,7 +24,8 @@ class GraphCyclesSpec extends AkkaSpec {
source ~> merge ~> Flow[Int].map { s => println(s); s } ~> bcast ~> Sink.ignore
merge <~ bcast
}
ClosedShape
})
//#deadlocked
// format: ON
}
@ -33,7 +34,7 @@ class GraphCyclesSpec extends AkkaSpec {
// format: OFF
//#unfair
// WARNING! The graph below stops consuming from "source" after a few steps
FlowGraph.closed() { implicit b =>
RunnableGraph.fromGraph(FlowGraph.create() { implicit b =>
import FlowGraph.Implicits._
val merge = b.add(MergePreferred[Int](1))
@ -41,7 +42,8 @@ class GraphCyclesSpec extends AkkaSpec {
source ~> merge ~> Flow[Int].map { s => println(s); s } ~> bcast ~> Sink.ignore
merge.preferred <~ bcast
}
ClosedShape
})
//#unfair
// format: ON
}
@ -49,7 +51,7 @@ class GraphCyclesSpec extends AkkaSpec {
"include a dropping cycle" in {
// format: OFF
//#dropping
FlowGraph.closed() { implicit b =>
RunnableGraph.fromGraph(FlowGraph.create() { implicit b =>
import FlowGraph.Implicits._
val merge = b.add(Merge[Int](2))
@ -57,7 +59,8 @@ class GraphCyclesSpec extends AkkaSpec {
source ~> merge ~> Flow[Int].map { s => println(s); s } ~> bcast ~> Sink.ignore
merge <~ Flow[Int].buffer(10, OverflowStrategy.dropHead) <~ bcast
}
ClosedShape
})
//#dropping
// format: ON
}
@ -66,7 +69,7 @@ class GraphCyclesSpec extends AkkaSpec {
// format: OFF
//#zipping-dead
// WARNING! The graph below never processes any elements
FlowGraph.closed() { implicit b =>
RunnableGraph.fromGraph(FlowGraph.create() { implicit b =>
import FlowGraph.Implicits._
val zip = b.add(ZipWith[Int, Int, Int]((left, right) => right))
@ -75,7 +78,8 @@ class GraphCyclesSpec extends AkkaSpec {
source ~> zip.in0
zip.out.map { s => println(s); s } ~> bcast ~> Sink.ignore
zip.in1 <~ bcast
}
ClosedShape
})
//#zipping-dead
// format: ON
}
@ -83,7 +87,7 @@ class GraphCyclesSpec extends AkkaSpec {
"include a live zipping cycle" in {
// format: OFF
//#zipping-live
FlowGraph.closed() { implicit b =>
RunnableGraph.fromGraph(FlowGraph.create() { implicit b =>
import FlowGraph.Implicits._
val zip = b.add(ZipWith((left: Int, right: Int) => left))
@ -95,7 +99,8 @@ class GraphCyclesSpec extends AkkaSpec {
zip.out.map { s => println(s); s } ~> bcast ~> Sink.ignore
zip.in1 <~ concat <~ start
concat <~ bcast
}
ClosedShape
})
//#zipping-live
// format: ON
}