diff --git a/akka-bench-jmh-dev/src/main/scala/akka/stream/MaterializationBenchmark.scala b/akka-bench-jmh-dev/src/main/scala/akka/stream/MaterializationBenchmark.scala index 415debc9c1..48db4f24c0 100644 --- a/akka-bench-jmh-dev/src/main/scala/akka/stream/MaterializationBenchmark.scala +++ b/akka-bench-jmh-dev/src/main/scala/akka/stream/MaterializationBenchmark.scala @@ -20,8 +20,8 @@ object MaterializationBenchmark { } val graphWithJunctionsBuilder = (numOfJunctions: Int) => - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val broadcast = b.add(Broadcast[Unit](numOfJunctions)) var outlet = broadcast.out(0) @@ -40,23 +40,23 @@ object MaterializationBenchmark { val graphWithNestedImportsBuilder = (numOfNestedGraphs: Int) => { var flow: Graph[FlowShape[Unit, Unit], Unit] = Flow[Unit].map(identity) for (_ <- 1 to numOfNestedGraphs) { - flow = FlowGraph.create(flow) { b ⇒ + flow = GraphDSL.create(flow) { b ⇒ flow ⇒ FlowShape(flow.inlet, flow.outlet) } } - RunnableGraph.fromGraph(FlowGraph.create(flow) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(flow) { implicit b ⇒ flow ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ Source.single(()) ~> flow ~> Sink.ignore ClosedShape }) } val graphWithImportedFlowBuilder = (numOfFlows: Int) => - RunnableGraph.fromGraph(FlowGraph.create(Source.single(())) { implicit b ⇒ source ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create(Source.single(())) { implicit b ⇒ source ⇒ + import GraphDSL.Implicits._ val flow = Flow[Unit].map(identity) var outlet: Outlet[Unit] = source.outlet for (i <- 0 until numOfFlows) { diff --git a/akka-docs-dev/rst/java/code/docs/MigrationsJava.java b/akka-docs-dev/rst/java/code/docs/MigrationsJava.java index c9444e6e54..8d35218ddc 100644 --- a/akka-docs-dev/rst/java/code/docs/MigrationsJava.java +++ b/akka-docs-dev/rst/java/code/docs/MigrationsJava.java @@ -80,12 +80,12 @@ public class MigrationsJava { { //#graph-create - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { //... return ClosedShape.getInstance(); }); - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { //... return new FlowShape<>(inlet, outlet); }); @@ -94,22 +94,22 @@ public class MigrationsJava { { //#graph-create-2 - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { //... return SourceShape.of(outlet); }); - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { //... return SinkShape.of(inlet); }); - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { //... return FlowShape.of(inlet, outlet); }); - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { //... return BidiShape.of(inlet1, outlet1, inlet2, outlet2); }); @@ -118,7 +118,7 @@ public class MigrationsJava { { //#graph-builder - FlowGraph.create(builder -> { + GraphDSL.create(builder -> { builder.from(outlet).toInlet(inlet); builder.from(outlet).via(builder.add(flow)).toInlet(inlet); builder.from(builder.add(Source.single(0))).to(builder.add(Sink.head())); diff --git a/akka-docs-dev/rst/java/migration-guide-1.0-2.x-java.rst b/akka-docs-dev/rst/java/migration-guide-1.0-2.x-java.rst index 4c453b54ef..5fe882b20d 100644 --- a/akka-docs-dev/rst/java/migration-guide-1.0-2.x-java.rst +++ b/akka-docs-dev/rst/java/migration-guide-1.0-2.x-java.rst @@ -86,18 +86,20 @@ Should be replaced by .. includecode:: code/docs/MigrationsJava.java#bidi-wrap -FlowGraph builder methods have been renamed -=========================================== +FlowGraph class and builder methods have been renamed +===================================================== +Due to incorrect overlap with the :class:`Flow` concept we renamed the :class:`FlowGraph` class to :class:`GraphDSL`. There is now only one graph creation method called ``create`` which is analogous to the old ``partial`` method. For closed graphs now it is explicitly required to return ``ClosedShape`` at the end of the builder block. Update procedure ---------------- -1. Replace all occurrences of ``FlowGraph.partial()`` or ``FlowGraph.closed()`` with ``FlowGraph.create()`` -2. Add ``ClosedShape`` as a return value of the builder block if it was ``FlowGraph.closed()`` before -3. Wrap the closed graph with ``RunnableGraph.fromGraph`` if it was ``FlowGraph.closed()`` before +1. Search and replace all occurrences of ``FlowGraph`` with ``GraphDSL``. +2. Replace all occurrences of ``GraphDSL.partial()`` or ``GraphDSL.closed()`` with ``GraphDSL.create()``. +3. Add ``ClosedShape`` as a return value of the builder block if it was ``FlowGraph.closed()`` before. +4. Wrap the closed graph with ``RunnableGraph.fromGraph`` if it was ``FlowGraph.closed()`` before. Example ^^^^^^^ @@ -125,7 +127,7 @@ Methods that create Source, Sink, Flow from Graphs have been removed Previously there were convenience methods available on ``Sink``, ``Source``, ``Flow`` an ``BidiFlow`` to create these DSL elements from a graph builder directly. Now this requires two explicit steps to reduce the number of overloaded methods (helps Java 8 type inference) and also reduces the ways how these elements can be created. There is only one -graph creation method to learn (``FlowGraph.create``) and then there is only one conversion method to use ``fromGraph()``. +graph creation method to learn (``GraphDSL.create``) and then there is only one conversion method to use ``fromGraph()``. This means that the following methods have been removed: - ``adapt()`` method on ``Source``, ``Sink``, ``Flow`` and ``BidiFlow`` (both DSLs) @@ -138,7 +140,7 @@ Update procedure Everywhere where ``Source``, ``Sink``, ``Flow`` and ``BidiFlow`` is created from a graph using a builder have to be replaced with two steps -1. Create a ``Graph`` with the correct ``Shape`` using ``FlowGraph.create`` (e.g.. for ``Source`` it means first +1. Create a ``Graph`` with the correct ``Shape`` using ``GraphDSL.create`` (e.g.. for ``Source`` it means first creating a ``Graph`` with ``SourceShape``) 2. Create the required DSL element by calling ``fromGraph()`` on the required DSL element (e.g. ``Source.fromGraph``) passing the graph created in the previous step diff --git a/akka-docs-dev/rst/java/stream-composition.rst b/akka-docs-dev/rst/java/stream-composition.rst index 419d829f71..27da645dd3 100644 --- a/akka-docs-dev/rst/java/stream-composition.rst +++ b/akka-docs-dev/rst/java/stream-composition.rst @@ -126,7 +126,7 @@ As a first example, let's look at a more complex layout: The diagram shows a :class:`RunnableGraph` (remember, if there are no unwired ports, the graph is closed, and therefore can be materialized) that encapsulates a non-trivial stream processing network. It contains fan-in, fan-out stages, -directed and non-directed cycles. The ``runnable()`` method of the :class:`FlowGraph` factory object allows the creation of a +directed and non-directed cycles. The ``runnable()`` method of the :class:`GraphDSL` factory object allows the creation of a general, closed, and runnable graph. For example the network on the diagram can be realized like this: .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/CompositionDocTest.java#complex-graph @@ -140,7 +140,7 @@ It is possible to refer to the ports, so another version might look like this: Similar to the case in the first section, so far we have not considered modularity. We created a complex graph, but the layout is flat, not modularized. We will modify our example, and create a reusable component with the graph DSL. -The way to do it is to use the ``create()`` method on :class:`FlowGraph` factory. If we remove the sources and sinks +The way to do it is to use the ``create()`` method on :class:`GraphDSL` factory. If we remove the sources and sinks from the previous example, what remains is a partial graph: | @@ -283,7 +283,7 @@ Attributes ---------- We have seen that we can use ``named()`` to introduce a nesting level in the fluid DSL (and also explicit nesting by using -``create()`` from :class:`FlowGraph`). Apart from having the effect of adding a nesting level, ``named()`` is actually +``create()`` from :class:`GraphDSL`). Apart from having the effect of adding a nesting level, ``named()`` is actually a shorthand for calling ``withAttributes(Attributes.name("someName"))``. Attributes provide a way to fine-tune certain aspects of the materialized running entity. For example buffer sizes can be controlled via attributes (see :ref:`stream-buffers-scala`). When it comes to hierarchic composition, attributes are inherited by nested modules, diff --git a/akka-docs-dev/rst/java/stream-customize.rst b/akka-docs-dev/rst/java/stream-customize.rst index 3400718184..01928a7fac 100644 --- a/akka-docs-dev/rst/java/stream-customize.rst +++ b/akka-docs-dev/rst/java/stream-customize.rst @@ -15,7 +15,7 @@ Custom processing with GraphStage ================================= The :class:`GraphStage` abstraction can be used to create arbitrary graph processing stages with any number of input -or output ports. It is a counterpart of the ``FlowGraph.create()`` method which creates new stream processing +or output ports. It is a counterpart of the ``GraphDSL.create()`` method which creates new stream processing stages by composing others. Where :class:`GraphStage` differs is that it creates a stage that is itself not divisible into smaller ones, and allows state to be maintained inside it in a safe way. diff --git a/akka-docs-dev/rst/java/stream-flows-and-basics.rst b/akka-docs-dev/rst/java/stream-flows-and-basics.rst index 90595350c7..382d249426 100644 --- a/akka-docs-dev/rst/java/stream-flows-and-basics.rst +++ b/akka-docs-dev/rst/java/stream-flows-and-basics.rst @@ -31,8 +31,11 @@ Back-pressure Non-Blocking Means that a certain operation does not hinder the progress of the calling thread, even if it takes long time to finish the requested operation. +Graph + A description of a stream processing topology, defining the pathways through which elements shall flow when the stream + is running. Processing Stage - The common name for all building blocks that build up a Flow or FlowGraph. + The common name for all building blocks that build up a Graph. Examples of a processing stage would be operations like ``map()``, ``filter()``, stages added by ``transform()`` like :class:`PushStage`, :class:`PushPullStage`, :class:`StatefulStage` and graph junctions like ``Merge`` or ``Broadcast``. For the full list of built-in processing stages see :ref:`stages-overview` @@ -67,7 +70,7 @@ it will be represented by the ``RunnableGraph`` type, indicating that it is read It is important to remember that even after constructing the ``RunnableGraph`` by connecting all the source, sink and different processing stages, no data will flow through it until it is materialized. Materialization is the process of -allocating all resources needed to run the computation described by a Flow (in Akka Streams this will often involve +allocating all resources needed to run the computation described by a Graph (in Akka Streams this will often involve starting up Actors). Thanks to Flows being simply a description of the processing pipeline they are *immutable, thread-safe, and freely shareable*, which means that it is for example safe to share and send them between actors, to have one actor prepare the work, and then have it be materialized at some completely different place in the code. @@ -200,11 +203,11 @@ Stream Materialization When constructing flows and graphs in Akka Streams think of them as preparing a blueprint, an execution plan. Stream materialization is the process of taking a stream description (the graph) and allocating all the necessary resources it needs in order to run. In the case of Akka Streams this often means starting up Actors which power the processing, -but is not restricted to that - it could also mean opening files or socket connections etc. – depending on what the stream needs. +but is not restricted to that—it could also mean opening files or socket connections etc.—depending on what the stream needs. Materialization is triggered at so called "terminal operations". Most notably this includes the various forms of the ``run()`` -and ``runWith()`` methods defined on flow elements as well as a small number of special syntactic sugars for running with -well-known sinks, such as ``runForeach(el -> )`` (being an alias to ``runWith(Sink.foreach(el -> ))``. +and ``runWith()`` methods defined on :class:`Source` or :class:`Flow` elements as well as a small number of special syntactic sugars for running with +well-known sinks, such as ``runForeach(el -> ...)`` (being an alias to ``runWith(Sink.foreach(el -> ...))``. Materialization is currently performed synchronously on the materializing thread. The actual stream processing is handled by actors started up during the streams materialization, @@ -212,7 +215,7 @@ which will be running on the thread pools they have been configured to run on - :class:`MaterializationSettings` while constructing the :class:`ActorMaterializer`. .. note:: - Reusing *instances* of linear computation stages (Source, Sink, Flow) inside FlowGraphs is legal, + Reusing *instances* of linear computation stages (Source, Sink, Flow) inside composite Graphs is legal, yet will materialize that stage multiple times. .. _flow-combine-mat-java: diff --git a/akka-docs-dev/rst/java/stream-graphs.rst b/akka-docs-dev/rst/java/stream-graphs.rst index 3d2cb93c00..d2c48ef744 100644 --- a/akka-docs-dev/rst/java/stream-graphs.rst +++ b/akka-docs-dev/rst/java/stream-graphs.rst @@ -17,9 +17,10 @@ streams, such that the second one is consumed after the first one has completed) .. _flow-graph-java: -Constructing Flow Graphs ------------------------- -Flow graphs are built from simple Flows which serve as the linear connections within the graphs as well as junctions +Constructing Graphs +------------------- + +Graphs are built from simple Flows which serve as the linear connections within the graphs as well as junctions which serve as fan-in and fan-out points for Flows. Thanks to the junctions having meaningful types based on their behaviour and making them explicit elements these elements should be rather straightforward to use. @@ -40,7 +41,7 @@ Akka Streams currently provide these junctions (for a detailed list see :ref:`st - ``Zip`` – *(2 inputs, 1 output)* is a :class:`ZipWith` specialised to zipping input streams of ``A`` and ``B`` into a ``Pair(A,B)`` tuple stream - ``Concat`` – *(2 inputs, 1 output)* concatenates two streams (first consume one, then the second one) -One of the goals of the FlowGraph DSL is to look similar to how one would draw a graph on a whiteboard, so that it is +One of the goals of the GraphDSL DSL is to look similar to how one would draw a graph on a whiteboard, so that it is simple to translate a design from whiteboard to code and be able to relate those two. Let's illustrate this by translating the below hand drawn graph into Akka Streams: @@ -53,15 +54,14 @@ or ending a :class:`Flow`. .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/FlowGraphDocTest.java#simple-flow-graph .. note:: - Junction *reference equality* defines *graph node equality* (i.e. the same merge *instance* used in a FlowGraph + Junction *reference equality* defines *graph node equality* (i.e. the same merge *instance* used in a GraphDSL refers to the same location in the resulting graph). - By looking at the snippets above, it should be apparent that the ``builder`` object is *mutable*. The reason for this design choice is to enable simpler creation of complex graphs, which may even contain cycles. -Once the FlowGraph has been constructed though, the :class:`RunnableGraph` instance *is immutable, thread-safe, and freely shareable*. -The same is true of all flow pieces—sources, sinks, and flows—once they are constructed. -This means that you can safely re-use one given Flow in multiple places in a processing graph. +Once the GraphDSL has been constructed though, the :class:`RunnableGraph` instance *is immutable, thread-safe, and freely shareable*. +The same is true of all graph pieces—sources, sinks, and flows—once they are constructed. +This means that you can safely re-use one given Flow or junction in multiple places in a processing graph. We have seen examples of such re-use already above: the merge and broadcast junctions were imported into the graph using ``builder.add(...)``, an operation that will make a copy of the blueprint that @@ -79,17 +79,17 @@ materialized as two connections between the corresponding Sources and Sinks: .. _partial-flow-graph-java: -Constructing and combining Partial Flow Graphs ----------------------------------------------- +Constructing and combining Partial Graphs +----------------------------------------- Sometimes it is not possible (or needed) to construct the entire computation graph in one place, but instead construct all of its different phases in different places and in the end connect them all into a complete graph and run it. -This can be achieved by using the returned :class:`Graph` from ``FlowGraph.create()`` rather than +This can be achieved by using the returned :class:`Graph` from ``GraphDSL.create()`` rather than passing it to ``RunnableGraph.fromGraph()`` to wrap it in a :class:`RunnableGraph`.The reason of representing it as a different type is that a :class:`RunnableGraph` requires all ports to be connected, and if they are not it will throw an exception at construction time, which helps to avoid simple -wiring errors while working with graphs. A partial flow graph however allows +wiring errors while working with graphs. A partial graph however allows you to return the set of yet to be connected ports from the code block that performs the internal wiring. @@ -105,10 +105,10 @@ then we import it (all of its nodes and connections) explicitly into the last gr the undefined elements are rewired to real sources and sinks. The graph can then be run and yields the expected result. .. warning:: - Please note that :class:`FlowGraph` is not able to provide compile time type-safety about whether or not all + Please note that :class:`GraphDSL` is not able to provide compile time type-safety about whether or not all elements have been properly connected—this validation is performed as a runtime check during the graph's instantiation. - A partial flow graph also verifies that all ports are either connected or part of the returned :class:`Shape`. + A partial graph also verifies that all ports are either connected or part of the returned :class:`Shape`. .. _constructing-sources-sinks-flows-from-partial-graphs-java: @@ -129,7 +129,7 @@ Being able to hide complex graphs inside of simple elements such as Sink / Sourc complex element and from there on treat it as simple compound stage for linear computations. In order to create a Source from a graph the method ``Source.fromGraph`` is used, to use it we must have a -``Graph`` with a ``SourceShape``. This is constructed using ``FlowGraph.create`` and providing building a ``SourceShape`` +``Graph`` with a ``SourceShape``. This is constructed using ``GraphDSL.create`` and providing building a ``SourceShape`` graph. The single outlet must be provided to the ``SourceShape.of`` method and will become “the sink that must be attached before this Source can run”. @@ -231,7 +231,7 @@ The following example demonstrates a case where the materialized ``Future`` of a Graph cycles, liveness and deadlocks ------------------------------------ -Cycles in bounded flow graphs need special considerations to avoid potential deadlocks and other liveness issues. +Cycles in bounded stream topologies need special considerations to avoid potential deadlocks and other liveness issues. This section shows several examples of problems that can arise from the presence of feedback arcs in stream processing graphs. diff --git a/akka-docs-dev/rst/java/stream-io.rst b/akka-docs-dev/rst/java/stream-io.rst index 7736ddf41d..b3f067845b 100644 --- a/akka-docs-dev/rst/java/stream-io.rst +++ b/akka-docs-dev/rst/java/stream-io.rst @@ -86,10 +86,10 @@ it makes sense to make the Server initiate the conversation by emitting a "hello .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/io/StreamTcpDocTest.java#welcome-banner-chat-server -The way we constructed a :class:`Flow` using a :class:`PartialFlowGraph` is explained in detail in +The way we constructed a :class:`Flow` using the :class:`GraphDSL` is explained in detail in :ref:`constructing-sources-sinks-flows-from-partial-graphs-java`, however the basic concepts is rather simple– we can encapsulate arbitrarily complex logic within a :class:`Flow` as long as it exposes the same interface, which means -exposing exactly one :class:`UndefinedSink` and exactly one :class:`UndefinedSource` which will be connected to the TCP +exposing exactly one :class:`Outlet` and exactly one :class:`Inlet` which will be connected to the TCP pipeline. In this example we use a :class:`Concat` graph processing stage to inject the initial message, and then continue with handling all incoming data using the echo handler. You should use this pattern of encapsulating complex logic in Flows and attaching those to :class:`StreamIO` in order to implement your custom and possibly sophisticated TCP servers. diff --git a/akka-docs-dev/rst/java/stream-quickstart.rst b/akka-docs-dev/rst/java/stream-quickstart.rst index 63f5d198ab..124730a572 100644 --- a/akka-docs-dev/rst/java/stream-quickstart.rst +++ b/akka-docs-dev/rst/java/stream-quickstart.rst @@ -107,13 +107,13 @@ Akka Streams intentionally separate the linear stream structures (Flows) from th in order to offer the most convenient API for both of these cases. Graphs can express arbitrarily complex stream setups at the expense of not reading as familiarly as collection transformations. -Graphs are constructed using :class:`FlowGraph` like this: +Graphs are constructed using :class:`GraphDSL` like this: .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/TwitterStreamQuickstartDocTest.java#flow-graph-broadcast As you can see, we use graph builder ``b`` to construct the graph using ``UniformFanOutShape`` and ``Flow`` s. -``FlowGraph.create`` returns a :class:`Graph`, in this example a ``Graph`` where +``GraphDSL.create`` returns a :class:`Graph`, in this example a ``Graph`` where :class:`ClosedShape` means that it is *a fully connected graph* or "closed" - there are no unconnected inputs or outputs. Since it is closed it is possible to transform the graph into a :class:`RunnableGraph` using ``RunnableGraph.fromGraph``. The runnable graph can then be ``run()`` to materialize a stream out of it. diff --git a/akka-docs-dev/rst/java/stream-rate.rst b/akka-docs-dev/rst/java/stream-rate.rst index 723eb945d3..1943bd6884 100644 --- a/akka-docs-dev/rst/java/stream-rate.rst +++ b/akka-docs-dev/rst/java/stream-rate.rst @@ -141,15 +141,15 @@ Rate transformation Understanding conflate ---------------------- -When a fast producer can not be informed to slow down by backpressure or some other signal, conflate might be useful to combine elements from a producer until a demand signal comes from a consumer. +When a fast producer can not be informed to slow down by backpressure or some other signal, ``conflate`` might be useful to combine elements from a producer until a demand signal comes from a consumer. Below is an example snippet that summarizes fast stream of elements to a standart deviation, mean and count of elements that have arrived while the stats have been calculated. .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/RateTransformationDocTest.java#conflate-summarize -This example demonstrates that such flow's rate is decoupled. Element rate at the start of the flow can be much higher that the element rate at the end of the flow. +This example demonstrates that such flow's rate is decoupled. The element rate at the start of the flow can be much higher that the element rate at the end of the flow. -Another possible use of conflate is to not consider all elements for summary when producer starts getting too fast. Example below demonstrates how conflate can be used to implement random drop of elements when consumer is not able to keep up with the producer. +Another possible use of ``conflate`` is to not consider all elements for summary when producer starts getting too fast. Example below demonstrates how ``conflate`` can be used to implement random drop of elements when consumer is not able to keep up with the producer. .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/RateTransformationDocTest.java#conflate-sample @@ -158,7 +158,7 @@ Understanding expand Expand helps to deal with slow producers which are unable to keep up with the demand coming from consumers. Expand allows to extrapolate a value to be sent as an element to a consumer. -As a simple use of expand here is a flow that sends the same element to consumer when producer does not send any new elements. +As a simple use of ``expand`` here is a flow that sends the same element to consumer when producer does not send any new elements. .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/RateTransformationDocTest.java#expand-last @@ -166,4 +166,4 @@ Expand also allows to keep some state between demand requests from the downstrea .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/RateTransformationDocTest.java#expand-drift -Note that all of the elements coming from upstream will go through expand at least once. This means that the output of this flow is going to report a drift of zero if producer is fast enough, or a larger drift otherwise. +Note that all of the elements coming from upstream will go through ``expand`` at least once. This means that the output of this flow is going to report a drift of zero if producer is fast enough, or a larger drift otherwise. diff --git a/akka-docs-dev/rst/scala/code/docs/MigrationsScala.scala b/akka-docs-dev/rst/scala/code/docs/MigrationsScala.scala index 1b157e5b85..bcfbd801a1 100644 --- a/akka-docs-dev/rst/scala/code/docs/MigrationsScala.scala +++ b/akka-docs-dev/rst/scala/code/docs/MigrationsScala.scala @@ -51,14 +51,14 @@ class MigrationsScala extends AkkaSpec { //#bidiflow-wrap //#graph-create - // Replaces FlowGraph.closed() - FlowGraph.create() { builder => + // Replaces GraphDSL.closed() + GraphDSL.create() { builder => //... ClosedShape } - // Replaces FlowGraph.partial() - FlowGraph.create() { builder => + // Replaces GraphDSL.partial() + GraphDSL.create() { builder => //... FlowShape(inlet, outlet) } @@ -66,25 +66,25 @@ class MigrationsScala extends AkkaSpec { //#graph-create-2 Source.fromGraph( - FlowGraph.create() { builder => + GraphDSL.create() { builder => //... SourceShape(outlet) }) Sink.fromGraph( - FlowGraph.create() { builder => + GraphDSL.create() { builder => //... SinkShape(inlet) }) Flow.fromGraph( - FlowGraph.create() { builder => + GraphDSL.create() { builder => //... FlowShape(inlet, outlet) }) BidiFlow.fromGraph( - FlowGraph.create() { builder => + GraphDSL.create() { builder => //... BidiShape(inlet1, outlet1, inlet2, outlet2) }) @@ -92,8 +92,8 @@ class MigrationsScala extends AkkaSpec { //#graph-edges RunnableGraph.fromGraph( - FlowGraph.create() { implicit builder => - import FlowGraph.Implicits._ + GraphDSL.create() { implicit builder => + import GraphDSL.Implicits._ outlet ~> inlet outlet ~> flow ~> inlet //... diff --git a/akka-docs-dev/rst/scala/code/docs/stream/BidiFlowDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/BidiFlowDocSpec.scala index 47995bf3d2..3ae58d4fd3 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/BidiFlowDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/BidiFlowDocSpec.scala @@ -44,7 +44,7 @@ object BidiFlowDocSpec { } //#codec-impl - val codecVerbose = BidiFlow.fromGraph(FlowGraph.create() { b => + val codecVerbose = BidiFlow.fromGraph(GraphDSL.create() { b => // construct and add the top flow, going outbound val outbound = b.add(Flow[Message].map(toBytes)) // construct and add the bottom flow, going inbound @@ -58,7 +58,7 @@ object BidiFlowDocSpec { //#codec //#framing - val framing = BidiFlow.fromGraph(FlowGraph.create() { b => + val framing = BidiFlow.fromGraph(GraphDSL.create() { b => implicit val order = ByteOrder.LITTLE_ENDIAN def addLengthHeader(bytes: ByteString) = { @@ -116,12 +116,12 @@ object BidiFlowDocSpec { }) //#framing - val chopUp = BidiFlow.fromGraph(FlowGraph.create() { b => + val chopUp = BidiFlow.fromGraph(GraphDSL.create() { b => val f = Flow[ByteString].mapConcat(_.map(ByteString(_))) BidiShape.fromFlows(b.add(f), b.add(f)) }) - val accumulate = BidiFlow.fromGraph(FlowGraph.create() { b => + val accumulate = BidiFlow.fromGraph(GraphDSL.create() { b => val f = Flow[ByteString].grouped(1000).map(_.fold(ByteString.empty)(_ ++ _)) BidiShape.fromFlows(b.add(f), b.add(f)) }) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/CompositionDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/CompositionDocSpec.scala index 3f58420996..e10e91e7d5 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/CompositionDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/CompositionDocSpec.scala @@ -76,8 +76,8 @@ class CompositionDocSpec extends AkkaSpec { "complex graph" in { // format: OFF //#complex-graph - import FlowGraph.Implicits._ - RunnableGraph.fromGraph(FlowGraph.create() { implicit builder => + import GraphDSL.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit builder => val A: Outlet[Int] = builder.add(Source.single(0)).outlet val B: UniformFanOutShape[Int, Int] = builder.add(Broadcast[Int](2)) val C: UniformFanInShape[Int, Int] = builder.add(Merge[Int](2)) @@ -96,8 +96,8 @@ class CompositionDocSpec extends AkkaSpec { //#complex-graph //#complex-graph-alt - import FlowGraph.Implicits._ - RunnableGraph.fromGraph(FlowGraph.create() { implicit builder => + import GraphDSL.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit builder => val B = builder.add(Broadcast[Int](2)) val C = builder.add(Merge[Int](2)) val E = builder.add(Balance[Int](2)) @@ -117,8 +117,8 @@ class CompositionDocSpec extends AkkaSpec { "partial graph" in { // format: OFF //#partial-graph - import FlowGraph.Implicits._ - val partial = FlowGraph.create() { implicit builder => + import GraphDSL.Implicits._ + val partial = GraphDSL.create() { implicit builder => val B = builder.add(Broadcast[Int](2)) val C = builder.add(Merge[Int](2)) val E = builder.add(Balance[Int](2)) @@ -143,7 +143,7 @@ class CompositionDocSpec extends AkkaSpec { val flow = Flow.fromGraph(partial) // Simple way to create a graph backed Source - val source = Source.fromGraph( FlowGraph.create() { implicit builder => + val source = Source.fromGraph( GraphDSL.create() { implicit builder => val merge = builder.add(Merge[Int](2)) Source.single(0) ~> merge Source(List(2, 3, 4)) ~> merge @@ -167,7 +167,7 @@ class CompositionDocSpec extends AkkaSpec { "closed graph" in { //#embed-closed val closed1 = Source.single(0).to(Sink.foreach(println)) - val closed2 = RunnableGraph.fromGraph(FlowGraph.create() { implicit builder => + val closed2 = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder => val embeddedClosed: ClosedShape = builder.add(closed1) // … embeddedClosed diff --git a/akka-docs-dev/rst/scala/code/docs/stream/FlowDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/FlowDocSpec.scala index 55792edd87..b6567a29e0 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/FlowDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/FlowDocSpec.scala @@ -148,9 +148,9 @@ class FlowDocSpec extends AkkaSpec { "various ways of transforming materialized values" in { import scala.concurrent.duration._ - val throttler = Flow.fromGraph(FlowGraph.create(Source.tick(1.second, 1.second, "test")) { implicit builder => + val throttler = Flow.fromGraph(GraphDSL.create(Source.tick(1.second, 1.second, "test")) { implicit builder => tickSource => - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val zip = builder.add(ZipWith[String, Int, Int](Keep.right)) tickSource ~> zip.in0 FlowShape(zip.in1, zip.out) @@ -211,9 +211,9 @@ class FlowDocSpec extends AkkaSpec { // The result of r11 can be also achieved by using the Graph API val r12: RunnableGraph[(Promise[Option[Int]], Cancellable, Future[Int])] = - RunnableGraph.fromGraph(FlowGraph.create(source, flow, sink)((_, _, _)) { implicit builder => + RunnableGraph.fromGraph(GraphDSL.create(source, flow, sink)((_, _, _)) { implicit builder => (src, f, dst) => - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ src ~> f ~> dst ClosedShape }) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/FlowGraphDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/FlowGraphDocSpec.scala index 3e30e79bd1..86ecec7527 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/FlowGraphDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/FlowGraphDocSpec.scala @@ -21,8 +21,8 @@ class FlowGraphDocSpec extends AkkaSpec { "build simple graph" in { //format: OFF //#simple-flow-graph - val g = RunnableGraph.fromGraph(FlowGraph.create() { implicit builder: FlowGraph.Builder[Unit] => - import FlowGraph.Implicits._ + val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: GraphDSL.Builder[Unit] => + import GraphDSL.Implicits._ val in = Source(1 to 10) val out = Sink.ignore @@ -46,8 +46,8 @@ class FlowGraphDocSpec extends AkkaSpec { "flow connection errors" in { intercept[IllegalArgumentException] { //#simple-graph - RunnableGraph.fromGraph(FlowGraph.create() { implicit builder => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit builder => + import GraphDSL.Implicits._ val source1 = Source(1 to 10) val source2 = Source(1 to 10) @@ -74,9 +74,9 @@ class FlowGraphDocSpec extends AkkaSpec { // format: OFF val g = //#flow-graph-reusing-a-flow - RunnableGraph.fromGraph(FlowGraph.create(topHeadSink, bottomHeadSink)((_, _)) { implicit builder => + RunnableGraph.fromGraph(GraphDSL.create(topHeadSink, bottomHeadSink)((_, _)) { implicit builder => (topHS, bottomHS) => - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val broadcast = builder.add(Broadcast[Int](2)) Source.single(1) ~> broadcast.in @@ -133,8 +133,8 @@ class FlowGraphDocSpec extends AkkaSpec { worker: Flow[In, Out, Any], workerCount: Int): Graph[PriorityWorkerPoolShape[In, Out], Unit] = { - FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val priorityMerge = b.add(MergePreferred[In](1)) val balance = b.add(Balance[In](workerCount)) @@ -168,8 +168,8 @@ class FlowGraphDocSpec extends AkkaSpec { val worker1 = Flow[String].map("step 1 " + _) val worker2 = Flow[String].map("step 2 " + _) - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val priorityPool1 = b.add(PriorityWorkerPool(worker1, 4)) val priorityPool2 = b.add(PriorityWorkerPool(worker2, 2)) @@ -203,8 +203,8 @@ class FlowGraphDocSpec extends AkkaSpec { "access to materialized value" in { //#flow-graph-matvalue - import FlowGraph.Implicits._ - val foldFlow: Flow[Int, Int, Future[Int]] = Flow.fromGraph(FlowGraph.create(Sink.fold[Int, Int](0)(_ + _)) { + import GraphDSL.Implicits._ + val foldFlow: Flow[Int, Int, Future[Int]] = Flow.fromGraph(GraphDSL.create(Sink.fold[Int, Int](0)(_ + _)) { implicit builder ⇒ fold ⇒ FlowShape(fold.inlet, builder.materializedValue.mapAsync(4)(identity).outlet) @@ -214,9 +214,9 @@ class FlowGraphDocSpec extends AkkaSpec { Await.result(Source(1 to 10).via(foldFlow).runWith(Sink.head), 3.seconds) should ===(55) //#flow-graph-matvalue-cycle - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ // This cannot produce any value: - val cyclicFold: Source[Int, Future[Int]] = Source.fromGraph(FlowGraph.create(Sink.fold[Int, Int](0)(_ + _)) { + val cyclicFold: Source[Int, Future[Int]] = Source.fromGraph(GraphDSL.create(Sink.fold[Int, Int](0)(_ + _)) { implicit builder => fold => // - Fold cannot complete until its upstream mapAsync completes diff --git a/akka-docs-dev/rst/scala/code/docs/stream/FlowParallelismDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/FlowParallelismDocSpec.scala index 4a28737f85..35da0a67b4 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/FlowParallelismDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/FlowParallelismDocSpec.scala @@ -1,12 +1,12 @@ package docs.stream import akka.stream.FlowShape -import akka.stream.scaladsl.{ FlowGraph, Merge, Balance, Source, Flow } +import akka.stream.scaladsl.{ GraphDSL, Merge, Balance, Source, Flow } import akka.stream.testkit.AkkaSpec class FlowParallelismDocSpec extends AkkaSpec { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ case class ScoopOfBatter() case class HalfCookedPancake() @@ -38,7 +38,7 @@ class FlowParallelismDocSpec extends AkkaSpec { val fryingPan: Flow[ScoopOfBatter, Pancake, Unit] = Flow[ScoopOfBatter].map { batter => Pancake() } - val pancakeChef: Flow[ScoopOfBatter, Pancake, Unit] = Flow.fromGraph(FlowGraph.create() { implicit builder => + val pancakeChef: Flow[ScoopOfBatter, Pancake, Unit] = Flow.fromGraph(GraphDSL.create() { implicit builder => val dispatchBatter = builder.add(Balance[ScoopOfBatter](2)) val mergePancakes = builder.add(Merge[Pancake](2)) @@ -59,7 +59,7 @@ class FlowParallelismDocSpec extends AkkaSpec { "Demonstrate parallelized pipelines" in { //#parallel-pipeline val pancakeChef: Flow[ScoopOfBatter, Pancake, Unit] = - Flow.fromGraph(FlowGraph.create() { implicit builder => + Flow.fromGraph(GraphDSL.create() { implicit builder => val dispatchBatter = builder.add(Balance[ScoopOfBatter](2)) val mergePancakes = builder.add(Merge[Pancake](2)) @@ -77,7 +77,7 @@ class FlowParallelismDocSpec extends AkkaSpec { "Demonstrate pipelined parallel processing" in { //#pipelined-parallel val pancakeChefs1: Flow[ScoopOfBatter, HalfCookedPancake, Unit] = - Flow.fromGraph(FlowGraph.create() { implicit builder => + Flow.fromGraph(GraphDSL.create() { implicit builder => val dispatchBatter = builder.add(Balance[ScoopOfBatter](2)) val mergeHalfPancakes = builder.add(Merge[HalfCookedPancake](2)) @@ -90,7 +90,7 @@ class FlowParallelismDocSpec extends AkkaSpec { }) val pancakeChefs2: Flow[HalfCookedPancake, Pancake, Unit] = - Flow.fromGraph(FlowGraph.create() { implicit builder => + Flow.fromGraph(GraphDSL.create() { implicit builder => val dispatchHalfPancakes = builder.add(Balance[HalfCookedPancake](2)) val mergePancakes = builder.add(Merge[Pancake](2)) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/GraphCyclesSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/GraphCyclesSpec.scala index 099c948ac5..893c01fa5b 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/GraphCyclesSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/GraphCyclesSpec.scala @@ -16,8 +16,8 @@ class GraphCyclesSpec extends AkkaSpec { // format: OFF //#deadlocked // WARNING! The graph below deadlocks! - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val merge = b.add(Merge[Int](2)) val bcast = b.add(Broadcast[Int](2)) @@ -34,8 +34,8 @@ class GraphCyclesSpec extends AkkaSpec { // format: OFF //#unfair // WARNING! The graph below stops consuming from "source" after a few steps - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val merge = b.add(MergePreferred[Int](1)) val bcast = b.add(Broadcast[Int](2)) @@ -51,8 +51,8 @@ class GraphCyclesSpec extends AkkaSpec { "include a dropping cycle" in { // format: OFF //#dropping - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val merge = b.add(Merge[Int](2)) val bcast = b.add(Broadcast[Int](2)) @@ -69,8 +69,8 @@ class GraphCyclesSpec extends AkkaSpec { // format: OFF //#zipping-dead // WARNING! The graph below never processes any elements - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val zip = b.add(ZipWith[Int, Int, Int]((left, right) => right)) val bcast = b.add(Broadcast[Int](2)) @@ -87,8 +87,8 @@ class GraphCyclesSpec extends AkkaSpec { "include a live zipping cycle" in { // format: OFF //#zipping-live - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val zip = b.add(ZipWith((left: Int, right: Int) => left)) val bcast = b.add(Broadcast[Int](2)) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/GraphStageDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/GraphStageDocSpec.scala index 06abf7e2ec..c317b60f04 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/GraphStageDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/GraphStageDocSpec.scala @@ -66,7 +66,7 @@ class GraphStageDocSpec extends AkkaSpec { //#custom-source-example //#simple-source-usage - // A GraphStage is a proper Graph, just like what FlowGraph.create would return + // A GraphStage is a proper Graph, just like what GraphDSL.create would return val sourceGraph: Graph[SourceShape[Int], Unit] = new NumbersSource // Create a Source from the Graph to access the DSL diff --git a/akka-docs-dev/rst/scala/code/docs/stream/StreamBuffersRateSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/StreamBuffersRateSpec.scala index 66eb995893..bf42f79d09 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/StreamBuffersRateSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/StreamBuffersRateSpec.scala @@ -39,8 +39,8 @@ class StreamBuffersRateSpec extends AkkaSpec { import scala.concurrent.duration._ case class Tick() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val zipper = b.add(ZipWith[Tick, Int, Int]((tick, count) => count)) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/StreamPartialFlowGraphDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/StreamPartialFlowGraphDocSpec.scala index f85562234f..dfbad7de08 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/StreamPartialFlowGraphDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/StreamPartialFlowGraphDocSpec.scala @@ -19,8 +19,8 @@ class StreamPartialFlowGraphDocSpec extends AkkaSpec { "build with open ports" in { //#simple-partial-flow-graph - val pickMaxOfThree = FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + val pickMaxOfThree = GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val zip1 = b.add(ZipWith[Int, Int, Int](math.max _)) val zip2 = b.add(ZipWith[Int, Int, Int](math.max _)) @@ -31,9 +31,9 @@ class StreamPartialFlowGraphDocSpec extends AkkaSpec { val resultSink = Sink.head[Int] - val g = RunnableGraph.fromGraph(FlowGraph.create(resultSink) { implicit b => + val g = RunnableGraph.fromGraph(GraphDSL.create(resultSink) { implicit b => sink => - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ // importing the partial graph will return its shape (inlets & outlets) val pm3 = b.add(pickMaxOfThree) @@ -52,8 +52,8 @@ class StreamPartialFlowGraphDocSpec extends AkkaSpec { "build source from partial flow graph" in { //#source-from-partial-flow-graph - val pairs = Source.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + val pairs = Source.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ // prepare graph elements val zip = b.add(Zip[Int, Int]()) @@ -75,8 +75,8 @@ class StreamPartialFlowGraphDocSpec extends AkkaSpec { "build flow from partial flow graph" in { //#flow-from-partial-flow-graph val pairUpWithToString = - Flow.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + Flow.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ // prepare graph elements val broadcast = b.add(Broadcast[Int](2)) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/TwitterStreamQuickstartDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/TwitterStreamQuickstartDocSpec.scala index 495b5711f9..3371ef37f6 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/TwitterStreamQuickstartDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/TwitterStreamQuickstartDocSpec.scala @@ -118,8 +118,8 @@ class TwitterStreamQuickstartDocSpec extends AkkaSpec { // format: OFF //#flow-graph-broadcast - val g = RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val bcast = b.add(Broadcast[Tweet](2)) tweets ~> bcast.in diff --git a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeCollectingMetrics.scala b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeCollectingMetrics.scala index 3ecf2d3e97..2fe19805e2 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeCollectingMetrics.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeCollectingMetrics.scala @@ -27,7 +27,7 @@ class RecipeCollectingMetrics extends RecipeSpec { // //#periodic-metrics-collection // val currentLoad = loadUpdates.transform(() => new HoldWithWait) // - // val graph = FlowGraph { implicit builder => + // val graph = GraphDSL { implicit builder => // import FlowGraphImplicits._ // val collector = ZipWith[Int, Tick, String]( // (load: Int, tick: Tick) => s"current load is $load") diff --git a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeDroppyBroadcast.scala b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeDroppyBroadcast.scala index 434edb08ee..71a26693b9 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeDroppyBroadcast.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeDroppyBroadcast.scala @@ -24,9 +24,9 @@ class RecipeDroppyBroadcast extends RecipeSpec { val mySink3 = Sink(sub3) //#droppy-bcast - val graph = RunnableGraph.fromGraph(FlowGraph.create(mySink1, mySink2, mySink3)((_, _, _)) { implicit b => + val graph = RunnableGraph.fromGraph(GraphDSL.create(mySink1, mySink2, mySink3)((_, _, _)) { implicit b => (sink1, sink2, sink3) => - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val bcast = b.add(Broadcast[Int](3)) myElements ~> bcast diff --git a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeGlobalRateLimit.scala b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeGlobalRateLimit.scala index fe4b3dba92..81f96ea400 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeGlobalRateLimit.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeGlobalRateLimit.scala @@ -99,8 +99,8 @@ class RecipeGlobalRateLimit extends RecipeSpec { val probe = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ val merge = b.add(Merge[String](2)) source1 ~> merge ~> Sink(probe) source2 ~> merge diff --git a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeManualTrigger.scala b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeManualTrigger.scala index 33771f9a38..36255071d2 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeManualTrigger.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeManualTrigger.scala @@ -18,8 +18,8 @@ class RecipeManualTrigger extends RecipeSpec { val sink = Sink(sub) //#manually-triggered-stream - val graph = RunnableGraph.fromGraph(FlowGraph.create() { implicit builder => - import FlowGraph.Implicits._ + val graph = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder => + import GraphDSL.Implicits._ val zip = builder.add(Zip[Message, Trigger]()) elements ~> zip.in0 triggerSource ~> zip.in1 @@ -57,8 +57,8 @@ class RecipeManualTrigger extends RecipeSpec { val sink = Sink(sub) //#manually-triggered-stream-zipwith - val graph = RunnableGraph.fromGraph(FlowGraph.create() { implicit builder => - import FlowGraph.Implicits._ + val graph = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder => + import GraphDSL.Implicits._ val zip = builder.add(ZipWith((msg: Message, trigger: Trigger) => msg)) elements ~> zip.in0 diff --git a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeWorkerPool.scala b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeWorkerPool.scala index 7aaf2a663f..9a17a79007 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeWorkerPool.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeWorkerPool.scala @@ -19,9 +19,9 @@ class RecipeWorkerPool extends RecipeSpec { //#worker-pool def balancer[In, Out](worker: Flow[In, Out, Any], workerCount: Int): Flow[In, Out, Unit] = { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ - Flow.fromGraph(FlowGraph.create() { implicit b => + Flow.fromGraph(GraphDSL.create() { implicit b => val balancer = b.add(Balance[In](workerCount, waitForAllDownstreams = true)) val merge = b.add(Merge[Out](workerCount)) diff --git a/akka-docs-dev/rst/scala/code/docs/stream/io/StreamTcpDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/io/StreamTcpDocSpec.scala index 5aad271beb..f902e79c92 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/io/StreamTcpDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/io/StreamTcpDocSpec.scala @@ -72,8 +72,8 @@ class StreamTcpDocSpec extends AkkaSpec { connections runForeach { connection => - val serverLogic = Flow.fromGraph(FlowGraph.create() { implicit b => - import FlowGraph.Implicits._ + val serverLogic = Flow.fromGraph(GraphDSL.create() { implicit b => + import GraphDSL.Implicits._ // server logic, parses incoming commands val commandParser = new PushStage[String, String] { diff --git a/akka-docs-dev/rst/scala/migration-guide-1.0-2.x-scala.rst b/akka-docs-dev/rst/scala/migration-guide-1.0-2.x-scala.rst index acde374a9b..12d6fd2602 100644 --- a/akka-docs-dev/rst/scala/migration-guide-1.0-2.x-scala.rst +++ b/akka-docs-dev/rst/scala/migration-guide-1.0-2.x-scala.rst @@ -92,18 +92,20 @@ Should be replaced by .. includecode:: code/docs/MigrationsScala.scala#bidiflow-wrap -FlowGraph builder methods have been renamed +FlowGraph class and builder methods have been renamed =========================================== +Due to incorrect overlap with the :class:`Flow` concept we renamed the :class:`FlowGraph` class to :class:`GraphDSL`. There is now only one graph creation method called ``create`` which is analogous to the old ``partial`` method. For closed graphs now it is explicitly required to return ``ClosedShape`` at the end of the builder block. Update procedure ---------------- -1. Replace all occurrences of ``FlowGraph.partial()`` or ``FlowGraph.closed()`` with ``FlowGraph.create()`` -2. Add ``ClosedShape`` as a return value of the builder block if it was ``FlowGraph.closed()`` before -3. Wrap the closed graph with ``RunnableGraph.fromGraph`` if it was ``FlowGraph.closed()`` before +1. Search and replace all occurrences of ``FlowGraph`` with ``GraphDSL``. +2. Replace all occurrences of ``GraphDSL.partial()`` or ``GraphDSL.closed()`` with ``GraphDSL.create()``. +3. Add ``ClosedShape`` as a return value of the builder block if it was ``FlowGraph.closed()`` before. +4. Wrap the closed graph with ``RunnableGraph.fromGraph`` if it was ``FlowGraph.closed()`` before. Example ^^^^^^^ @@ -131,7 +133,7 @@ Methods that create Source, Sink, Flow from Graphs have been removed Previously there were convenience methods available on ``Sink``, ``Source``, ``Flow`` an ``BidiFlow`` to create these DSL elements from a graph builder directly. Now this requires two explicit steps to reduce the number of overloaded methods (helps Java 8 type inference) and also reduces the ways how these elements can be created. There is only one -graph creation method to learn (``FlowGraph.create``) and then there is only one conversion method to use ``fromGraph()``. +graph creation method to learn (``GraphDSL.create``) and then there is only one conversion method to use ``fromGraph()``. This means that the following methods have been removed: - ``adapt()`` method on ``Source``, ``Sink``, ``Flow`` and ``BidiFlow`` (both DSLs) @@ -144,7 +146,7 @@ Update procedure Everywhere where ``Source``, ``Sink``, ``Flow`` and ``BidiFlow`` is created from a graph using a builder have to be replaced with two steps -1. Create a ``Graph`` with the correct ``Shape`` using ``FlowGraph.create`` (e.g.. for ``Source`` it means first +1. Create a ``Graph`` with the correct ``Shape`` using ``GraphDSL.create`` (e.g.. for ``Source`` it means first creating a ``Graph`` with ``SourceShape``) 2. Create the required DSL element by calling ``fromGraph()`` on the required DSL element (e.g. ``Source.fromGraph``) passing the graph created in the previous step @@ -187,7 +189,7 @@ Several Graph builder methods have been removed The ``addEdge`` methods have been removed from the DSL to reduce the ways connections can be made and to reduce the number of overloads. Now only the ``~>`` notation is available which requires the import of the implicits -``FlowGraph.Implicits._``. +``GraphDSL.Implicits._``. Update procedure ---------------- diff --git a/akka-docs-dev/rst/scala/stream-composition.rst b/akka-docs-dev/rst/scala/stream-composition.rst index cf84512f6d..592141b384 100644 --- a/akka-docs-dev/rst/scala/stream-composition.rst +++ b/akka-docs-dev/rst/scala/stream-composition.rst @@ -126,7 +126,7 @@ As a first example, let's look at a more complex layout: The diagram shows a :class:`RunnableGraph` (remember, if there are no unwired ports, the graph is closed, and therefore can be materialized) that encapsulates a non-trivial stream processing network. It contains fan-in, fan-out stages, -directed and non-directed cycles. The ``runnable()`` method of the :class:`FlowGraph` object allows the creation of a +directed and non-directed cycles. The ``runnable()`` method of the :class:`GraphDSL` object allows the creation of a general, closed, and runnable graph. For example the network on the diagram can be realized like this: .. includecode:: code/docs/stream/CompositionDocSpec.scala#complex-graph @@ -141,7 +141,7 @@ explicitly, and it is not necessary to import our linear stages via ``add()``, s Similar to the case in the first section, so far we have not considered modularity. We created a complex graph, but the layout is flat, not modularized. We will modify our example, and create a reusable component with the graph DSL. -The way to do it is to use the ``create()`` factory method on :class:`FlowGraph`. If we remove the sources and sinks +The way to do it is to use the ``create()`` factory method on :class:`GraphDSL`. If we remove the sources and sinks from the previous example, what remains is a partial graph: | @@ -284,7 +284,7 @@ Attributes ---------- We have seen that we can use ``named()`` to introduce a nesting level in the fluid DSL (and also explicit nesting by using -``create()`` from :class:`FlowGraph`). Apart from having the effect of adding a nesting level, ``named()`` is actually +``create()`` from :class:`GraphDSL`). Apart from having the effect of adding a nesting level, ``named()`` is actually a shorthand for calling ``withAttributes(Attributes.name("someName"))``. Attributes provide a way to fine-tune certain aspects of the materialized running entity. For example buffer sizes can be controlled via attributes (see :ref:`stream-buffers-scala`). When it comes to hierarchic composition, attributes are inherited by nested modules, diff --git a/akka-docs-dev/rst/scala/stream-customize.rst b/akka-docs-dev/rst/scala/stream-customize.rst index ca98db0150..a50268e869 100644 --- a/akka-docs-dev/rst/scala/stream-customize.rst +++ b/akka-docs-dev/rst/scala/stream-customize.rst @@ -15,7 +15,7 @@ Custom processing with GraphStage ================================= The :class:`GraphStage` abstraction can be used to create arbitrary graph processing stages with any number of input -or output ports. It is a counterpart of the ``FlowGraph.create()`` method which creates new stream processing +or output ports. It is a counterpart of the ``GraphDSL.create()`` method which creates new stream processing stages by composing others. Where :class:`GraphStage` differs is that it creates a stage that is itself not divisible into smaller ones, and allows state to be maintained inside it in a safe way. diff --git a/akka-docs-dev/rst/scala/stream-flows-and-basics.rst b/akka-docs-dev/rst/scala/stream-flows-and-basics.rst index f1379f8057..205e428056 100644 --- a/akka-docs-dev/rst/scala/stream-flows-and-basics.rst +++ b/akka-docs-dev/rst/scala/stream-flows-and-basics.rst @@ -31,8 +31,11 @@ Back-pressure Non-Blocking Means that a certain operation does not hinder the progress of the calling thread, even if it takes long time to finish the requested operation. +Graph + A description of a stream processing topology, defining the pathways through which elements shall flow when the stream + is running. Processing Stage - The common name for all building blocks that build up a Flow or FlowGraph. + The common name for all building blocks that build up a Graph. Examples of a processing stage would be operations like ``map()``, ``filter()``, stages added by ``transform()`` like :class:`PushStage`, :class:`PushPullStage`, :class:`StatefulStage` and graph junctions like ``Merge`` or ``Broadcast``. For the full list of built-in processing stages see :ref:`stages-overview` @@ -67,7 +70,7 @@ it will be represented by the ``RunnableGraph`` type, indicating that it is read It is important to remember that even after constructing the ``RunnableGraph`` by connecting all the source, sink and different processing stages, no data will flow through it until it is materialized. Materialization is the process of -allocating all resources needed to run the computation described by a Flow (in Akka Streams this will often involve +allocating all resources needed to run the computation described by a Graph (in Akka Streams this will often involve starting up Actors). Thanks to Flows being simply a description of the processing pipeline they are *immutable, thread-safe, and freely shareable*, which means that it is for example safe to share and send them between actors, to have one actor prepare the work, and then have it be materialized at some completely different place in the code. @@ -204,11 +207,11 @@ Stream Materialization When constructing flows and graphs in Akka Streams think of them as preparing a blueprint, an execution plan. Stream materialization is the process of taking a stream description (the graph) and allocating all the necessary resources it needs in order to run. In the case of Akka Streams this often means starting up Actors which power the processing, -but is not restricted to that - it could also mean opening files or socket connections etc. – depending on what the stream needs. +but is not restricted to that—it could also mean opening files or socket connections etc.—depending on what the stream needs. Materialization is triggered at so called "terminal operations". Most notably this includes the various forms of the ``run()`` -and ``runWith()`` methods defined on flow elements as well as a small number of special syntactic sugars for running with -well-known sinks, such as ``runForeach(el => )`` (being an alias to ``runWith(Sink.foreach(el => ))``. +and ``runWith()`` methods defined on :class:`Source` and :class:`Flow` elements as well as a small number of special syntactic sugars for running with +well-known sinks, such as ``runForeach(el => ...)`` (being an alias to ``runWith(Sink.foreach(el => ...))``. Materialization is currently performed synchronously on the materializing thread. The actual stream processing is handled by actors started up during the streams materialization, @@ -216,7 +219,7 @@ which will be running on the thread pools they have been configured to run on - :class:`MaterializationSettings` while constructing the :class:`ActorMaterializer`. .. note:: - Reusing *instances* of linear computation stages (Source, Sink, Flow) inside FlowGraphs is legal, + Reusing *instances* of linear computation stages (Source, Sink, Flow) inside composite Graphs is legal, yet will materialize that stage multiple times. .. _flow-combine-mat-scala: diff --git a/akka-docs-dev/rst/scala/stream-graphs.rst b/akka-docs-dev/rst/scala/stream-graphs.rst index 4be72c9bba..db34c43719 100644 --- a/akka-docs-dev/rst/scala/stream-graphs.rst +++ b/akka-docs-dev/rst/scala/stream-graphs.rst @@ -17,10 +17,10 @@ streams, such that the second one is consumed after the first one has completed) .. _flow-graph-scala: -Constructing Flow Graphs ------------------------- +Constructing Graphs +------------------- -Flow graphs are built from simple Flows which serve as the linear connections within the graphs as well as junctions +Graphs are built from simple Flows which serve as the linear connections within the graphs as well as junctions which serve as fan-in and fan-out points for Flows. Thanks to the junctions having meaningful types based on their behaviour and making them explicit elements these elements should be rather straightforward to use. @@ -41,7 +41,7 @@ Akka Streams currently provide these junctions (for a detailed list see :ref:`st - ``Zip[A,B]`` – *(2 inputs, 1 output)* is a :class:`ZipWith` specialised to zipping input streams of ``A`` and ``B`` into an ``(A,B)`` tuple stream - ``Concat[A]`` – *(2 inputs, 1 output)* concatenates two streams (first consume one, then the second one) -One of the goals of the FlowGraph DSL is to look similar to how one would draw a graph on a whiteboard, so that it is +One of the goals of the GraphDSL DSL is to look similar to how one would draw a graph on a whiteboard, so that it is simple to translate a design from whiteboard to code and be able to relate those two. Let's illustrate this by translating the below hand drawn graph into Akka Streams: @@ -55,18 +55,18 @@ will be inferred. .. includecode:: code/docs/stream/FlowGraphDocSpec.scala#simple-flow-graph .. note:: - Junction *reference equality* defines *graph node equality* (i.e. the same merge *instance* used in a FlowGraph + Junction *reference equality* defines *graph node equality* (i.e. the same merge *instance* used in a GraphDSL refers to the same location in the resulting graph). -Notice the ``import FlowGraph.Implicits._`` which brings into scope the ``~>`` operator (read as "edge", "via" or "to") +Notice the ``import GraphDSL.Implicits._`` which brings into scope the ``~>`` operator (read as "edge", "via" or "to") and its inverted counterpart ``<~`` (for noting down flows in the opposite direction where appropriate). -By looking at the snippets above, it should be apparent that the :class:`FlowGraph.Builder` object is *mutable*. +By looking at the snippets above, it should be apparent that the :class:`GraphDSL.Builder` object is *mutable*. It is used (implicitly) by the ``~>`` operator, also making it a mutable operation as well. The reason for this design choice is to enable simpler creation of complex graphs, which may even contain cycles. -Once the FlowGraph has been constructed though, the :class:`FlowGraph` instance *is immutable, thread-safe, and freely shareable*. -The same is true of all flow pieces—sources, sinks, and flows—once they are constructed. -This means that you can safely re-use one given Flow in multiple places in a processing graph. +Once the GraphDSL has been constructed though, the :class:`GraphDSL` instance *is immutable, thread-safe, and freely shareable*. +The same is true of all graph pieces—sources, sinks, and flows—once they are constructed. +This means that you can safely re-use one given Flow or junction in multiple places in a processing graph. We have seen examples of such re-use already above: the merge and broadcast junctions were imported into the graph using ``builder.add(...)``, an operation that will make a copy of the blueprint that @@ -84,18 +84,18 @@ materialized as two connections between the corresponding Sources and Sinks: .. _partial-flow-graph-scala: -Constructing and combining Partial Flow Graphs ----------------------------------------------- +Constructing and combining Partial Graphs +----------------------------------------- Sometimes it is not possible (or needed) to construct the entire computation graph in one place, but instead construct all of its different phases in different places and in the end connect them all into a complete graph and run it. This can be achieved by returning a different ``Shape`` than ``ClosedShape``, for example ``FlowShape(in, out)``, from the -function given to ``FlowGraph.create``. See :ref:`predefined_shapes`) for a list of such predefined shapes. +function given to ``GraphDSL.create``. See :ref:`predefined_shapes`) for a list of such predefined shapes. Making a ``Graph`` a :class:`RunnableGraph` requires all ports to be connected, and if they are not it will throw an exception at construction time, which helps to avoid simple -wiring errors while working with graphs. A partial flow graph however allows +wiring errors while working with graphs. A partial graph however allows you to return the set of yet to be connected ports from the code block that performs the internal wiring. @@ -112,10 +112,10 @@ the undefined elements are rewired to real sources and sinks. The graph can then .. warning:: - Please note that :class:`FlowGraph` is not able to provide compile time type-safety about whether or not all + Please note that :class:`GraphDSL` is not able to provide compile time type-safety about whether or not all elements have been properly connected—this validation is performed as a runtime check during the graph's instantiation. - A partial flow graph also verifies that all ports are either connected or part of the returned :class:`Shape`. + A partial graph also verifies that all ports are either connected or part of the returned :class:`Shape`. .. _constructing-sources-sinks-flows-from-partial-graphs-scala: @@ -136,7 +136,7 @@ Being able to hide complex graphs inside of simple elements such as Sink / Sourc complex element and from there on treat it as simple compound stage for linear computations. In order to create a Source from a graph the method ``Source.fromGraph`` is used, to use it we must have a -``Graph[SourceShape, T]``. This is constructed using ``FlowGraph.create`` and returning a ``SourceShape`` +``Graph[SourceShape, T]``. This is constructed using ``GraphDSL.create`` and returning a ``SourceShape`` from the function passed in . The single outlet must be provided to the ``SourceShape.of`` method and will become “the sink that must be attached before this Source can run”. @@ -283,7 +283,7 @@ The following example demonstrates a case where the materialized ``Future`` of a Graph cycles, liveness and deadlocks ------------------------------------ -Cycles in bounded flow graphs need special considerations to avoid potential deadlocks and other liveness issues. +Cycles in bounded stream topologies need special considerations to avoid potential deadlocks and other liveness issues. This section shows several examples of problems that can arise from the presence of feedback arcs in stream processing graphs. diff --git a/akka-docs-dev/rst/scala/stream-io.rst b/akka-docs-dev/rst/scala/stream-io.rst index 3693d163f5..c7ec89e7ef 100644 --- a/akka-docs-dev/rst/scala/stream-io.rst +++ b/akka-docs-dev/rst/scala/stream-io.rst @@ -86,10 +86,10 @@ it makes sense to make the Server initiate the conversation by emitting a "hello .. includecode:: code/docs/stream/io/StreamTcpDocSpec.scala#welcome-banner-chat-server -The way we constructed a :class:`Flow` using a :class:`PartialFlowGraph` is explained in detail in +The way we constructed a :class:`Flow` using the :class:`GraphDSL` is explained in detail in :ref:`constructing-sources-sinks-flows-from-partial-graphs-scala`, however the basic concepts is rather simple– we can encapsulate arbitrarily complex logic within a :class:`Flow` as long as it exposes the same interface, which means -exposing exactly one :class:`UndefinedSink` and exactly one :class:`UndefinedSource` which will be connected to the TCP +exposing exactly one :class:`Outlet` and exactly one :class:`Inlet` which will be connected to the TCP pipeline. In this example we use a :class:`Concat` graph processing stage to inject the initial message, and then continue with handling all incoming data using the echo handler. You should use this pattern of encapsulating complex logic in Flows and attaching those to :class:`StreamIO` in order to implement your custom and possibly sophisticated TCP servers. diff --git a/akka-docs-dev/rst/scala/stream-quickstart.rst b/akka-docs-dev/rst/scala/stream-quickstart.rst index 85651f9036..19e3ae04ce 100644 --- a/akka-docs-dev/rst/scala/stream-quickstart.rst +++ b/akka-docs-dev/rst/scala/stream-quickstart.rst @@ -103,15 +103,15 @@ Akka Streams intentionally separate the linear stream structures (Flows) from th in order to offer the most convenient API for both of these cases. Graphs can express arbitrarily complex stream setups at the expense of not reading as familiarly as collection transformations. -Graphs are constructed using :class:`FlowGraph` like this: +Graphs are constructed using :class:`GraphDSL` like this: .. includecode:: code/docs/stream/TwitterStreamQuickstartDocSpec.scala#flow-graph-broadcast -As you can see, inside the :class:`FlowGraph` we use an implicit graph builder ``b`` to mutably construct the graph +As you can see, inside the :class:`GraphDSL` we use an implicit graph builder ``b`` to mutably construct the graph using the ``~>`` "edge operator" (also read as "connect" or "via" or "to"). The operator is provided implicitly -by importing ``FlowGraph.Implicits._``. +by importing ``GraphDSL.Implicits._``. -``FlowGraph.create`` returns a :class:`Graph`, in this example a :class:`Graph[ClosedShape, Unit]` where +``GraphDSL.create`` returns a :class:`Graph`, in this example a :class:`Graph[ClosedShape, Unit]` where :class:`ClosedShape` means that it is *a fully connected graph* or "closed" - there are no unconnected inputs or outputs. Since it is closed it is possible to transform the graph into a :class:`RunnableGraph` using ``RunnableGraph.fromGraph``. The runnable graph can then be ``run()`` to materialize a stream out of it. diff --git a/akka-docs-dev/rst/scala/stream-rate.rst b/akka-docs-dev/rst/scala/stream-rate.rst index 5a543d16f5..3e43493afa 100644 --- a/akka-docs-dev/rst/scala/stream-rate.rst +++ b/akka-docs-dev/rst/scala/stream-rate.rst @@ -75,7 +75,7 @@ Here is an example of a code that demonstrate some of the issues caused by inter .. includecode:: code/docs/stream/StreamBuffersRateSpec.scala#buffering-abstraction-leak -Running the above example one would expect the number *3* to be printed in every 3 seconds (the ``conflate`` step here +Running the above example one would expect the number *3* to be printed in every 3 seconds (the ``cUndefinedSourceonflate`` step here is configured so that it counts the number of elements received before the downstream ``ZipWith`` consumes them). What is being printed is different though, we will see the number *1*. The reason for this is the internal buffer which is by default 16 elements large, and prefetches elements before the ``ZipWith`` starts consuming them. It is possible @@ -141,15 +141,15 @@ Rate transformation Understanding conflate ---------------------- -When a fast producer can not be informed to slow down by backpressure or some other signal, conflate might be useful to combine elements from a producer until a demand signal comes from a consumer. +When a fast producer can not be informed to slow down by backpressure or some other signal, ``conflate`` might be useful to combine elements from a producer until a demand signal comes from a consumer. Below is an example snippet that summarizes fast stream of elements to a standart deviation, mean and count of elements that have arrived while the stats have been calculated. .. includecode:: code/docs/stream/RateTransformationDocSpec.scala#conflate-summarize -This example demonstrates that such flow's rate is decoupled. Element rate at the start of the flow can be much higher that the element rate at the end of the flow. +This example demonstrates that such flow's rate is decoupled. The element rate at the start of the flow can be much higher that the element rate at the end of the flow. -Another possible use of conflate is to not consider all elements for summary when producer starts getting too fast. Example below demonstrates how conflate can be used to implement random drop of elements when consumer is not able to keep up with the producer. +Another possible use of ``conflate`` is to not consider all elements for summary when producer starts getting too fast. Example below demonstrates how ``conflate`` can be used to implement random drop of elements when consumer is not able to keep up with the producer. .. includecode:: code/docs/stream/RateTransformationDocSpec.scala#conflate-sample @@ -158,7 +158,7 @@ Understanding expand Expand helps to deal with slow producers which are unable to keep up with the demand coming from consumers. Expand allows to extrapolate a value to be sent as an element to a consumer. -As a simple use of expand here is a flow that sends the same element to consumer when producer does not send any new elements. +As a simple use of ``expand`` here is a flow that sends the same element to consumer when producer does not send any new elements. .. includecode:: code/docs/stream/RateTransformationDocSpec.scala#expand-last @@ -166,4 +166,4 @@ Expand also allows to keep some state between demand requests from the downstrea .. includecode:: code/docs/stream/RateTransformationDocSpec.scala#expand-drift -Note that all of the elements coming from upstream will go through expand at least once. This means that the output of this flow is going to report a drift of zero if producer is fast enough, or a larger drift otherwise. +Note that all of the elements coming from upstream will go through ``expand`` at least once. This means that the output of this flow is going to report a drift of zero if producer is fast enough, or a larger drift otherwise. diff --git a/akka-docs-dev/rst/stream-design.rst b/akka-docs-dev/rst/stream-design.rst index 2336be2429..85bc4263eb 100644 --- a/akka-docs-dev/rst/stream-design.rst +++ b/akka-docs-dev/rst/stream-design.rst @@ -25,36 +25,36 @@ This means that we provide all the tools necessary to express any stream process Resulting Implementation Constraints ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Compositionality entails reusability of partial stream topologies, which led us to the lifted approach of describing data flows as (partial) FlowGraphs that can act as composite sources, flows (a.k.a. pipes) and sinks of data. These building blocks shall then be freely shareable, with the ability to combine them freely to form larger flows. The representation of these pieces must therefore be an immutable blueprint that is materialized in an explicit step in order to start the stream processing. The resulting stream processing engine is then also immutable in the sense of having a fixed topology that is prescribed by the blueprint. Dynamic networks need to be modeled by explicitly using the Reactive Streams interfaces for plugging different engines together. +Compositionality entails reusability of partial stream topologies, which led us to the lifted approach of describing data flows as (partial) graphs that can act as composite sources, flows (a.k.a. pipes) and sinks of data. These building blocks shall then be freely shareable, with the ability to combine them freely to form larger graphs. The representation of these pieces must therefore be an immutable blueprint that is materialized in an explicit step in order to start the stream processing. The resulting stream processing engine is then also immutable in the sense of having a fixed topology that is prescribed by the blueprint. Dynamic networks need to be modeled by explicitly using the Reactive Streams interfaces for plugging different engines together. -The process of materialization may be parameterized, e.g. instantiating a blueprint for handling a TCP connection’s data with specific information about the connection’s address and port information. Additionally, materialization will often create specific objects that are useful to interact with the processing engine once it is running, for example for shutting it down or for extracting metrics. This means that the materialization function takes a set of parameters from the outside and it produces a set of results. Compositionality demands that these two sets cannot interact, because that would establish a covert channel by which different pieces could communicate, leading to problems of initialization order and inscrutable runtime failures. - -Another aspect of materialization is that we want to support distributed stream processing, meaning that both the parameters and the results need to be location transparent—either serializable immutable values or ActorRefs. Using for example Futures would restrict materialization to the local JVM. There may be cases for which this will typically not be a severe restriction (like opening a TCP connection), but the principle remains. +The process of materialization will often create specific objects that are useful to interact with the processing engine once it is running, for example for shutting it down or for extracting metrics. This means that the materialization function produces a result termed the *materialized value of a graph*. Interoperation with other Reactive Streams implementations ---------------------------------------------------------- -Akka Streams fully implement the Reactive Streams specification and interoperate with all other conformant implementations. We chose to completely separate the Reactive Streams interfaces (which we regard to be an SPI) from the user-level API. In order to obtain a :class:`Publisher` or :class:`Subscriber` from an Akka Stream topology, a corresponding ``Sink.publisher`` or ``Source.subscriber`` element must be used. +Akka Streams fully implement the Reactive Streams specification and interoperate with all other conformant implementations. We chose to completely separate the Reactive Streams interfaces from the user-level API because we regard them to be an SPI that is not targeted at endusers. In order to obtain a :class:`Publisher` or :class:`Subscriber` from an Akka Stream topology, a corresponding ``Sink.publisher`` or ``Source.subscriber`` element must be used. All stream Processors produced by the default materialization of Akka Streams are restricted to having a single Subscriber, additional Subscribers will be rejected. The reason for this is that the stream topologies described using our DSL never require fan-out behavior from the Publisher sides of the elements, all fan-out is done using explicit elements like :class:`Broadcast[T]`. -This means that ``Sink.publisher(true)`` must be used where broadcast behavior is needed for interoperation with other Reactive Streams implementations. +This means that ``Sink.publisher(true)`` (for enabling fan-out support) must be used where broadcast behavior is needed for interoperation with other Reactive Streams implementations. What shall users of streaming libraries expect? ----------------------------------------------- We expect libraries to be built on top of Akka Streams, in fact Akka HTTP is one such example that lives within the Akka project itself. In order to allow users to profit from the principles that are described for Akka Streams above, the following rules are established: - * libraries shall provide their users with reusable pieces, allowing full compositionality - * libraries may optionally and additionally provide facilities that consume and materialize flow descriptions + * libraries shall provide their users with reusable pieces, i.e. expose factories that return graphs, allowing full compositionality + * libraries may optionally and additionally provide facilities that consume and materialize graphs -The reasoning behind the first rule is that compositionality would be destroyed if different libraries only accepted flow descriptions and expected to materialize them: using two of these together would be impossible because materialization can only happen once. As a consequence, the functionality of a library must be expressed such that materialization can be done by the user, outside of the library’s control. +The reasoning behind the first rule is that compositionality would be destroyed if different libraries only accepted graphs and expected to materialize them: using two of these together would be impossible because materialization can only happen once. As a consequence, the functionality of a library must be expressed such that materialization can be done by the user, outside of the library’s control. The second rule allows a library to additionally provide nice sugar for the common case, an example of which is the Akka HTTP API that provides a ``handleWith`` method for convenient materialization. .. note:: One important consequence of this is that a reusable flow description cannot be bound to “live” resources, any connection to or allocation of such resources must be deferred until materialization time. Examples of “live” resources are already existing TCP connections, a multicast Publisher, etc.; a TickSource does not fall into this category if its timer is created only upon materialization (as is the case for our implementation). + + Exceptions from this need to be well-justified and carefully documented. Resulting Implementation Constraints ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ Akka Streams must enable a library to express any stream processing utility in t * Source: something with exactly one output stream * Sink: something with exactly one input stream * Flow: something with exactly one input and one output stream - * BidirectionalFlow: something with exactly two input streams and two output streams that conceptually behave like two Flows of opposite direction + * BidiFlow: something with exactly two input streams and two output streams that conceptually behave like two Flows of opposite direction * Graph: a packaged stream processing topology that exposes a certain set of input and output ports, characterized by an object of type :class:`Shape`. .. note:: @@ -87,23 +87,6 @@ The ability for failures to propagate faster than data elements is essential for The semantics of stream recovery ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A recovery element (i.e. any transformation that absorbs an ``onError`` signal and turns that into possibly more data elements followed normal stream completion) acts as a bulkhead that confines a stream collapse to a given region of the flow topology. Within the collapsed region buffered elements may be lost, but the outside is not affected by the failure. +A recovery element (i.e. any transformation that absorbs an ``onError`` signal and turns that into possibly more data elements followed normal stream completion) acts as a bulkhead that confines a stream collapse to a given region of the stream topology. Within the collapsed region buffered elements may be lost, but the outside is not affected by the failure. This works in the same fashion as a ``try``–``catch`` expression: it marks a region in which exceptions are caught, but the exact amount of code that was skipped within this region in case of a failure might not be known precisely—the placement of statements matters. - -The finer points of stream materialization ------------------------------------------- - -.. note:: - - This is not yet implemented as stated here, this document illustrates intent. - -It is commonly necessary to parameterize a flow so that it can be materialized for different arguments, an example would be the handler Flow that is given to a server socket implementation and materialized for each incoming connection with information about the peer’s address. On the other hand it is frequently necessary to retrieve specific objects that result from materialization, for example a ``Future[Unit]`` that signals the completion of a ``ForeachSink``. - -It might be tempting to allow different pieces of a flow topology to access the materialization results of other pieces in order to customize their behavior, but that would violate composability and reusability as argued above. Therefore the arguments and results of materialization need to be segregated: - - * The Materializer is configured with a (type-safe) mapping from keys to values, which is exposed to the processing stages during their materialization. - * The values in this mapping may act as channels, for example by using a Promise/Future pair to communicate a value; another possibility for such information-passing is of course to explicitly model it as a stream of configuration data elements within the graph itself. - * The materialized values obtained from the processing stages are combined as prescribed by the user, but can of course be dependent on the values in the argument mapping. - -To avoid having to use ``Future`` values as key bindings, materialization itself may become fully asynchronous. This would allow for example the use of the bound server port within the rest of the flow, and only if the port was actually bound successfully. The downside is that some APIs will then return ``Future[MaterializedMap]``, which means that others will have to accept this in turn in order to keep the usage burden as low as possible. diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/client/OutgoingConnectionBlueprint.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/client/OutgoingConnectionBlueprint.scala index 12b94bfb90..1205a1ddc4 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/client/OutgoingConnectionBlueprint.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/client/OutgoingConnectionBlueprint.scala @@ -76,8 +76,8 @@ private[http] object OutgoingConnectionBlueprint { case (MessageStartError(_, info), _) ⇒ throw IllegalResponseException(info) } - val core = BidiFlow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val core = BidiFlow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val methodBypassFanout = b.add(Broadcast[HttpRequest](2, eagerCancel = true)) val responseParsingMerge = b.add(new ResponseParsingMerge(rootParser)) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolConductor.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolConductor.scala index 3662170935..c3dcbe748a 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolConductor.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolConductor.scala @@ -65,8 +65,8 @@ private object PoolConductor { */ def apply(slotCount: Int, pipeliningLimit: Int, log: LoggingAdapter): Graph[Ports, Any] = - FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val retryMerge = b.add(MergePreferred[RequestContext](1, eagerClose = true)) val slotSelector = b.add(new SlotSelector(slotCount, pipeliningLimit, log)) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolFlow.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolFlow.scala index 42aea1c9c2..06ece1d27c 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolFlow.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolFlow.scala @@ -70,9 +70,9 @@ private object PoolFlow { def apply(connectionFlow: Flow[HttpRequest, HttpResponse, Future[Http.OutgoingConnection]], remoteAddress: InetSocketAddress, settings: ConnectionPoolSettings, log: LoggingAdapter)( implicit system: ActorSystem, fm: Materializer): Flow[RequestContext, ResponseContext, Unit] = - Flow.fromGraph(FlowGraph.create[FlowShape[RequestContext, ResponseContext]]() { implicit b ⇒ + Flow.fromGraph(GraphDSL.create[FlowShape[RequestContext, ResponseContext]]() { implicit b ⇒ import settings._ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val conductor = b.add(PoolConductor(maxConnections, pipeliningLimit, log)) val slots = Vector diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala index e5cd6fd5e7..4cd31cf6a5 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala @@ -55,8 +55,8 @@ private object PoolSlot { remoteAddress: InetSocketAddress, // TODO: remove after #16168 is cleared settings: ConnectionPoolSettings)(implicit system: ActorSystem, fm: Materializer): Graph[FanOutShape2[RequestContext, ResponseContext, RawSlotEvent], Any] = - FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ // TODO wouldn't be better to have them under a known parent? /user/SlotProcessor-0 seems weird val name = slotProcessorActorName.next() diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/rendering/RenderSupport.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/rendering/RenderSupport.scala index 5b1b3c1dc2..a81d914f75 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/rendering/RenderSupport.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/rendering/RenderSupport.scala @@ -32,9 +32,9 @@ private object RenderSupport { val defaultLastChunkBytes: ByteString = renderChunk(HttpEntity.LastChunk) def CancelSecond[T, Mat](first: Source[T, Mat], second: Source[T, Any]): Source[T, Mat] = { - Source.fromGraph(FlowGraph.create(first) { implicit b ⇒ + Source.fromGraph(GraphDSL.create(first) { implicit b ⇒ frst ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ second ~> Sink.cancelled SourceShape(frst.outlet) }) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala index 00c2f10540..3ec2faa585 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala @@ -66,8 +66,8 @@ private[http] object HttpServerBluePrint { def websocketSupport(settings: ServerSettings, log: LoggingAdapter)(implicit mat: Materializer): BidiFlow[ResponseRenderingOutput, ByteString, ByteString, ByteString, Unit] = { val ws = websocketSetup - BidiFlow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + BidiFlow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val switch = b.add(new ProtocolSwitchStage(ws.installHandler, settings.websocketRandomFactory, log)) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/ws/Websocket.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/ws/Websocket.scala index 4b7b6cc705..b7813ee513 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/ws/Websocket.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/ws/Websocket.scala @@ -121,8 +121,8 @@ private[http] object Websocket { MessageToFrameRenderer.create(serverSide) .named("ws-render-messages") - BidiFlow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + BidiFlow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val split = b.add(BypassRouter) val tick = Source.tick(closeTimeout, closeTimeout, Tick) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/ws/WebsocketClientBlueprint.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/ws/WebsocketClientBlueprint.scala index 02f7e34fd4..428af5d0b4 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/ws/WebsocketClientBlueprint.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/ws/WebsocketClientBlueprint.scala @@ -109,8 +109,8 @@ object WebsocketClientBlueprint { } } - BidiFlow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + BidiFlow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val networkIn = b.add(Flow[ByteString].transform(() ⇒ new UpgradeStage)) val wsIn = b.add(Flow[ByteString]) diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/HighLevelOutgoingConnectionSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/HighLevelOutgoingConnectionSpec.scala index 2e91cb0f17..462b534fe1 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/HighLevelOutgoingConnectionSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/HighLevelOutgoingConnectionSpec.scala @@ -44,8 +44,8 @@ class HighLevelOutgoingConnectionSpec extends AkkaSpec { val connFlow = Http().outgoingConnection(serverHostName, serverPort) val C = 4 - val doubleConnection = Flow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val doubleConnection = Flow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val bcast = b.add(Broadcast[HttpRequest](C)) val merge = b.add(Merge[HttpResponse](C)) diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/LowLevelOutgoingConnectionSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/LowLevelOutgoingConnectionSpec.scala index 639c20c8f2..f1589e1ad9 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/LowLevelOutgoingConnectionSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/LowLevelOutgoingConnectionSpec.scala @@ -526,9 +526,9 @@ class LowLevelOutgoingConnectionSpec extends AkkaSpec("akka.loggers = []\n akka. val netOut = TestSubscriber.manualProbe[ByteString] val netIn = TestPublisher.manualProbe[ByteString]() - RunnableGraph.fromGraph(FlowGraph.create(OutgoingConnectionBlueprint(Host("example.com"), settings, NoLogging)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(OutgoingConnectionBlueprint(Host("example.com"), settings, NoLogging)) { implicit b ⇒ client ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ Source(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> client.in2 client.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) ⇒ x } ~> Sink(netOut) Source(requests) ~> client.in1 diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerTestSetupBase.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerTestSetupBase.scala index 9f88bcdb54..8c5fc1ed35 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerTestSetupBase.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerTestSetupBase.scala @@ -34,9 +34,9 @@ abstract class HttpServerTestSetupBase { val netIn = TestPublisher.probe[ByteString]() val netOut = ByteStringSinkProbe() - RunnableGraph.fromGraph(FlowGraph.create(HttpServerBluePrint(settings, remoteAddress = remoteAddress, log = NoLogging)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(HttpServerBluePrint(settings, remoteAddress = remoteAddress, log = NoLogging)) { implicit b ⇒ server ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ Source(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> server.in2 server.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) ⇒ x } ~> netOut.sink server.out2 ~> Sink(requests) diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/MessageSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/MessageSpec.scala index 90583939af..175f1063e7 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/MessageSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/MessageSpec.scala @@ -822,7 +822,7 @@ class MessageSpec extends FreeSpec with Matchers with WithMaterializerSpec { val messageHandler: Flow[Message, Message, Unit] = Flow.fromGraph { - FlowGraph.create() { implicit b ⇒ + GraphDSL.create() { implicit b ⇒ val in = b.add(Sink(messageIn)).inlet val out = b.add(Source(messageOut)).outlet diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WebsocketClientSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WebsocketClientSpec.scala index e5fc2bcd4b..fd7d5697fb 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WebsocketClientSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WebsocketClientSpec.scala @@ -312,9 +312,9 @@ class WebsocketClientSpec extends FreeSpec with Matchers with WithMaterializerSp val netIn = TestPublisher.probe[ByteString]() val graph = - RunnableGraph.fromGraph(FlowGraph.create(clientLayer) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(clientLayer) { implicit b ⇒ client ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ Source(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> client.in2 client.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) ⇒ x } ~> netOut.sink client.out2 ~> clientImplementation ~> client.in1 diff --git a/akka-stream-testkit/src/test/scala/akka/stream/testkit/TwoStreamsSetup.scala b/akka-stream-testkit/src/test/scala/akka/stream/testkit/TwoStreamsSetup.scala index 326d87a759..69d515c258 100644 --- a/akka-stream-testkit/src/test/scala/akka/stream/testkit/TwoStreamsSetup.scala +++ b/akka-stream-testkit/src/test/scala/akka/stream/testkit/TwoStreamsSetup.scala @@ -9,18 +9,18 @@ import akka.stream.testkit.Utils._ abstract class TwoStreamsSetup extends BaseTwoStreamsSetup { - abstract class Fixture(b: FlowGraph.Builder[_]) { + abstract class Fixture(b: GraphDSL.Builder[_]) { def left: Inlet[Int] def right: Inlet[Int] def out: Outlet[Outputs] } - def fixture(b: FlowGraph.Builder[_]): Fixture + def fixture(b: GraphDSL.Builder[_]): Fixture override def setup(p1: Publisher[Int], p2: Publisher[Int]) = { val subscriber = TestSubscriber.probe[Outputs]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val f = fixture(b) Source(p1) ~> f.left diff --git a/akka-stream-tests/src/test/java/akka/stream/javadsl/BidiFlowTest.java b/akka-stream-tests/src/test/java/akka/stream/javadsl/BidiFlowTest.java index 94eae7469a..bb4973a437 100644 --- a/akka-stream-tests/src/test/java/akka/stream/javadsl/BidiFlowTest.java +++ b/akka-stream-tests/src/test/java/akka/stream/javadsl/BidiFlowTest.java @@ -19,7 +19,7 @@ import scala.runtime.BoxedUnit; import akka.japi.Pair; import akka.stream.*; import akka.stream.testkit.AkkaSpec; -import akka.stream.javadsl.FlowGraph.Builder; +import akka.stream.javadsl.GraphDSL.Builder; import akka.japi.function.*; import akka.util.ByteString; import static org.junit.Assert.assertEquals; @@ -35,8 +35,8 @@ public class BidiFlowTest extends StreamTest { "FlowTest", AkkaSpec.testConf()); private final BidiFlow bidi = BidiFlow - .fromGraph(FlowGraph.create( - new Function, BidiShape>() { + .fromGraph(GraphDSL.create( + new Function, BidiShape>() { @Override public BidiShape apply(Builder b) throws Exception { @@ -61,8 +61,8 @@ public class BidiFlowTest extends StreamTest { private final BidiFlow inverse = BidiFlow .fromGraph( - FlowGraph.create( - new Function, BidiShape>() { + GraphDSL.create( + new Function, BidiShape>() { @Override public BidiShape apply(Builder b) throws Exception { @@ -87,9 +87,9 @@ public class BidiFlowTest extends StreamTest { private final BidiFlow> bidiMat = BidiFlow.fromGraph( - FlowGraph.create( + GraphDSL.create( Sink.head(), - new Function2>, SinkShape, BidiShape>() { + new Function2>, SinkShape, BidiShape>() { @Override public BidiShape apply(Builder> b, SinkShape sink) throws Exception { @@ -126,7 +126,7 @@ public class BidiFlowTest extends StreamTest { @Test public void mustWorkInIsolation() throws Exception { final Pair, Future> p = - RunnableGraph.fromGraph(FlowGraph + RunnableGraph.fromGraph(GraphDSL .create(Sink. head(), Sink. head(), Keep., Future> both(), new Function3, Future>>, SinkShape, SinkShape, ClosedShape>() { @@ -202,7 +202,7 @@ public class BidiFlowTest extends StreamTest { @Test public void mustMaterializeToItsValue() throws Exception { final Future f = RunnableGraph.fromGraph( - FlowGraph.create(bidiMat, + GraphDSL.create(bidiMat, new Function2 >, BidiShape, ClosedShape>() { @Override public ClosedShape apply(Builder> b, @@ -231,7 +231,7 @@ public class BidiFlowTest extends StreamTest { @Test public void mustCombineMaterializationValues() throws Exception { - final Flow> left = Flow.fromGraph(FlowGraph.create( + final Flow> left = Flow.fromGraph(GraphDSL.create( Sink.head(), new Function2>, SinkShape, FlowShape>() { @Override public FlowShape apply(Builder> b, @@ -251,7 +251,7 @@ public class BidiFlowTest extends StreamTest { return new FlowShape(flow.inlet(), merge.out()); } })); - final Flow>> right = Flow.fromGraph(FlowGraph.create( + final Flow>> right = Flow.fromGraph(GraphDSL.create( Sink.>head(), new Function2>>, SinkShape>, FlowShape>() { @Override public FlowShape apply(Builder>> b, diff --git a/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowGraphTest.java b/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowGraphTest.java index 337775e5ac..0ddede4ec3 100644 --- a/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowGraphTest.java +++ b/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowGraphTest.java @@ -7,7 +7,7 @@ import akka.japi.Pair; import akka.pattern.Patterns; import akka.japi.tuple.Tuple4; import akka.stream.*; -import akka.stream.javadsl.FlowGraph.Builder; +import akka.stream.javadsl.GraphDSL.Builder; import akka.stream.stage.*; import akka.japi.function.*; import akka.stream.testkit.AkkaSpec; @@ -70,7 +70,7 @@ public class FlowGraphTest extends StreamTest { final Sink> publisher = Sink.publisher(false); final Source source = Source.fromGraph( - FlowGraph.create(new Function, SourceShape>() { + GraphDSL.create(new Function, SourceShape>() { @Override public SourceShape apply(Builder b) throws Exception { final UniformFanInShape merge = b.add(Merge.create(2)); @@ -94,7 +94,7 @@ public class FlowGraphTest extends StreamTest { final Iterable input1 = Arrays.asList("A", "B", "C"); final Iterable input2 = Arrays.asList(1, 2, 3); - RunnableGraph.fromGraph( FlowGraph.create( + RunnableGraph.fromGraph( GraphDSL.create( new Function,ClosedShape>() { @Override public ClosedShape apply(final Builder b) throws Exception { @@ -129,7 +129,7 @@ public class FlowGraphTest extends StreamTest { final Iterable expected1 = Arrays.asList("A", "B", "C"); final Iterable expected2 = Arrays.asList(1, 2, 3); - RunnableGraph.fromGraph(FlowGraph.create( + RunnableGraph.fromGraph(GraphDSL.create( new Function, ClosedShape>() { @Override public ClosedShape apply(final Builder b) throws Exception { @@ -161,7 +161,7 @@ public class FlowGraphTest extends StreamTest { final JavaTestKit probe1 = new JavaTestKit(system); final JavaTestKit probe2 = new JavaTestKit(system); - RunnableGraph.fromGraph(FlowGraph.create( + RunnableGraph.fromGraph(GraphDSL.create( new Function, ClosedShape>() { @Override public ClosedShape apply(final Builder b) throws Exception { @@ -204,7 +204,7 @@ public class FlowGraphTest extends StreamTest { final JavaTestKit probe3 = new JavaTestKit(system); final JavaTestKit probe4 = new JavaTestKit(system); - RunnableGraph.fromGraph(FlowGraph.create( + RunnableGraph.fromGraph(GraphDSL.create( new Function, ClosedShape>() { @Override public ClosedShape apply(final Builder b) throws Exception { @@ -258,7 +258,7 @@ public class FlowGraphTest extends StreamTest { } }); - final Future future = RunnableGraph.fromGraph(FlowGraph.create(Sink.head(), + final Future future = RunnableGraph.fromGraph(GraphDSL.create(Sink.head(), new Function2>, SinkShape, ClosedShape>() { @Override public ClosedShape apply(Builder> b, SinkShape out) throws Exception { @@ -289,7 +289,7 @@ public class FlowGraphTest extends StreamTest { }); final Future future = RunnableGraph.fromGraph( - FlowGraph.create(Sink.head(), + GraphDSL.create(Sink.head(), new Function2>, SinkShape, ClosedShape>() { @Override public ClosedShape apply(Builder> b, SinkShape out) throws Exception { @@ -314,7 +314,7 @@ public class FlowGraphTest extends StreamTest { final TestProbe probe = TestProbe.apply(system); final Future future = RunnableGraph.fromGraph( - FlowGraph.create(Sink. head(), new Function2>, SinkShape, ClosedShape>() { + GraphDSL.create(Sink. head(), new Function2>, SinkShape, ClosedShape>() { @Override public ClosedShape apply(Builder> b, SinkShape out) throws Exception { b.from(b.add(Source.single(1))).to(out); diff --git a/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowTest.java b/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowTest.java index 75cb2cf011..f3a18821f4 100644 --- a/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowTest.java +++ b/akka-stream-tests/src/test/java/akka/stream/javadsl/FlowTest.java @@ -11,7 +11,7 @@ import akka.japi.Pair; import akka.japi.function.*; import akka.stream.*; import akka.stream.impl.ConstantFun; -import akka.stream.javadsl.FlowGraph.Builder; +import akka.stream.javadsl.GraphDSL.Builder; import akka.stream.stage.*; import akka.stream.testkit.AkkaSpec; import akka.stream.testkit.TestPublisher; @@ -390,7 +390,7 @@ public class FlowTest extends StreamTest { final Sink> publisher = Sink.publisher(false); final Source source = Source.fromGraph( - FlowGraph.create(new Function, SourceShape>() { + GraphDSL.create(new Function, SourceShape>() { @Override public SourceShape apply(Builder b) throws Exception { final UniformFanInShape merge = b.add(Merge.create(2)); @@ -414,7 +414,7 @@ public class FlowTest extends StreamTest { final Iterable input1 = Arrays.asList("A", "B", "C"); final Iterable input2 = Arrays.asList(1, 2, 3); - RunnableGraph.fromGraph(FlowGraph.create(new Function, ClosedShape>(){ + RunnableGraph.fromGraph(GraphDSL.create(new Function, ClosedShape>(){ public ClosedShape apply(Builder b) { final Outlet in1 = b.add(Source.from(input1)).outlet(); final Outlet in2 = b.add(Source.from(input2)).outlet(); @@ -646,7 +646,7 @@ public class FlowTest extends StreamTest { @Test public void mustBeAbleToBroadcastEagerCancel() throws Exception { final Sink sink = Sink.fromGraph( - FlowGraph.create(new Function, SinkShape>() { + GraphDSL.create(new Function, SinkShape>() { @Override public SinkShape apply(Builder b) throws Exception { final UniformFanOutShape broadcast = b.add(Broadcast.create(2, true)); diff --git a/akka-stream-tests/src/test/scala/akka/stream/DslFactoriesConsistencySpec.scala b/akka-stream-tests/src/test/scala/akka/stream/DslFactoriesConsistencySpec.scala index cff1129312..16b3794e83 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/DslFactoriesConsistencySpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/DslFactoriesConsistencySpec.scala @@ -70,7 +70,7 @@ class DslFactoriesConsistencySpec extends WordSpec with Matchers { TestCase("Flow", scaladsl.Flow.getClass, javadsl.Flow.getClass), TestCase("Sink", scaladsl.Sink.getClass, javadsl.Sink.getClass), TestCase("BidiFlow", scaladsl.BidiFlow.getClass, javadsl.BidiFlow.getClass), - TestCase("FlowGraph", scaladsl.FlowGraph.getClass, javadsl.FlowGraph.getClass, classOf[javadsl.GraphCreate]), + TestCase("GraphDSL", scaladsl.GraphDSL.getClass, javadsl.GraphDSL.getClass, classOf[javadsl.GraphCreate]), TestCase("ZipWith", Some(scaladsl.ZipWith.getClass), None, Some(javadsl.ZipWith.getClass)), TestCase("Merge", scaladsl.Merge.getClass, javadsl.Merge.getClass), TestCase("MergePreferred", scaladsl.MergePreferred.getClass, javadsl.MergePreferred.getClass), @@ -113,8 +113,8 @@ class DslFactoriesConsistencySpec extends WordSpec with Matchers { Ignore(_ == akka.stream.scaladsl.Flow.getClass, _ == "apply", _ == 24, _ ⇒ true), Ignore(_ == akka.stream.scaladsl.Sink.getClass, _ == "apply", _ == 24, _ ⇒ true), Ignore(_ == akka.stream.scaladsl.BidiFlow.getClass, _ == "apply", _ == 24, _ ⇒ true), - Ignore(_ == akka.stream.scaladsl.FlowGraph.getClass, _ == "runnable", _ == 24, _ ⇒ true), - Ignore(_ == akka.stream.scaladsl.FlowGraph.getClass, _ == "create", _ == 24, _ ⇒ true), + Ignore(_ == akka.stream.scaladsl.GraphDSL.getClass, _ == "runnable", _ == 24, _ ⇒ true), + Ignore(_ == akka.stream.scaladsl.GraphDSL.getClass, _ == "create", _ == 24, _ ⇒ true), // all generated methods like scaladsl.Sink$.akka$stream$scaladsl$Sink$$newOnCompleteStage$1 Ignore(_ ⇒ true, _.contains("$"), _ ⇒ true, _ ⇒ true)) diff --git a/akka-stream-tests/src/test/scala/akka/stream/actor/ActorPublisherSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/actor/ActorPublisherSpec.scala index f4e516a8c8..bb7461b48a 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/actor/ActorPublisherSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/actor/ActorPublisherSpec.scala @@ -339,7 +339,7 @@ class ActorPublisherSpec extends AkkaSpec(ActorPublisherSpec.config) with Implic } } - "work in a FlowGraph" in { + "work in a GraphDSL" in { implicit val materializer = ActorMaterializer() val probe1 = TestProbe() val probe2 = TestProbe() @@ -350,9 +350,9 @@ class ActorPublisherSpec extends AkkaSpec(ActorPublisherSpec.config) with Implic val sink1 = Sink(ActorSubscriber[String](system.actorOf(receiverProps(probe1.ref)))) val sink2: Sink[String, ActorRef] = Sink.actorSubscriber(receiverProps(probe2.ref)) - val senderRef2 = RunnableGraph.fromGraph(FlowGraph.create(Source.actorPublisher[Int](senderProps)) { implicit b ⇒ + val senderRef2 = RunnableGraph.fromGraph(GraphDSL.create(Source.actorPublisher[Int](senderProps)) { implicit b ⇒ source2 ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val merge = b.add(Merge[Int](2)) val bcast = b.add(Broadcast[String](2)) diff --git a/akka-stream-tests/src/test/scala/akka/stream/impl/TimeoutsSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/impl/TimeoutsSpec.scala index de6fad3546..9375afaa03 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/impl/TimeoutsSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/impl/TimeoutsSpec.scala @@ -174,8 +174,8 @@ class TimeoutsSpec extends AkkaSpec { val downWrite = TestPublisher.probe[Int]() val downRead = TestSubscriber.probe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val timeoutStage = b.add(BidiFlow.bidirectionalIdleTimeout[String, Int](2.seconds)) Source(upWrite) ~> timeoutStage.in1; timeoutStage.out1 ~> Sink(downRead) @@ -222,8 +222,8 @@ class TimeoutsSpec extends AkkaSpec { val downWrite = TestPublisher.probe[Int]() val downRead = TestSubscriber.probe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val timeoutStage = b.add(BidiFlow.bidirectionalIdleTimeout[String, Int](2.seconds)) Source(upWrite) ~> timeoutStage.in1; timeoutStage.out1 ~> Sink(downRead) diff --git a/akka-stream-tests/src/test/scala/akka/stream/impl/fusing/ActorGraphInterpreterSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/impl/fusing/ActorGraphInterpreterSpec.scala index 0eadb8a826..60aac913ae 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/impl/fusing/ActorGraphInterpreterSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/impl/fusing/ActorGraphInterpreterSpec.scala @@ -214,9 +214,9 @@ class ActorGraphInterpreterSpec extends AkkaSpec { val takeAll = Flow[Int].grouped(200).toMat(Sink.head)(Keep.right) - val (f1, f2) = RunnableGraph.fromGraph(FlowGraph.create(takeAll, takeAll)(Keep.both) { implicit b ⇒ + val (f1, f2) = RunnableGraph.fromGraph(GraphDSL.create(takeAll, takeAll)(Keep.both) { implicit b ⇒ (out1, out2) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val bidi = b.add(rotatedBidi) Source(1 to 10) ~> bidi.in1 diff --git a/akka-stream-tests/src/test/scala/akka/stream/io/TlsSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/io/TlsSpec.scala index 86bcaf1eea..25999308dd 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/io/TlsSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/io/TlsSpec.scala @@ -85,7 +85,7 @@ class TlsSpec extends AkkaSpec("akka.loglevel=INFO\nakka.actor.debug.receive=off import system.dispatcher implicit val materializer = ActorMaterializer() - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "SslTls" must { @@ -399,7 +399,7 @@ class TlsSpec extends AkkaSpec("akka.loglevel=INFO\nakka.actor.debug.receive=off "reliably cancel subscriptions when TransportIn fails early" in assertAllStagesStopped { val ex = new Exception("hello") val (sub, out1, out2) = - RunnableGraph.fromGraph(FlowGraph.create(Source.subscriber[SslTlsOutbound], Sink.head[ByteString], Sink.head[SslTlsInbound])((_, _, _)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(Source.subscriber[SslTlsOutbound], Sink.head[ByteString], Sink.head[SslTlsInbound])((_, _, _)) { implicit b ⇒ (s, o1, o2) ⇒ val tls = b.add(clientTls(EagerClose)) s ~> tls.in1; tls.out1 ~> o1 @@ -417,7 +417,7 @@ class TlsSpec extends AkkaSpec("akka.loglevel=INFO\nakka.actor.debug.receive=off "reliably cancel subscriptions when UserIn fails early" in assertAllStagesStopped { val ex = new Exception("hello") val (sub, out1, out2) = - RunnableGraph.fromGraph(FlowGraph.create(Source.subscriber[ByteString], Sink.head[ByteString], Sink.head[SslTlsInbound])((_, _, _)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(Source.subscriber[ByteString], Sink.head[ByteString], Sink.head[SslTlsInbound])((_, _, _)) { implicit b ⇒ (s, o1, o2) ⇒ val tls = b.add(clientTls(EagerClose)) Source.failed[SslTlsOutbound](ex) ~> tls.in1; tls.out1 ~> o1 diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/BidiFlowSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/BidiFlowSpec.scala index 302d9d1b86..88ae8fa4fb 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/BidiFlowSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/BidiFlowSpec.scala @@ -14,7 +14,7 @@ import scala.collection.immutable class BidiFlowSpec extends AkkaSpec with ConversionCheckedTripleEquals { import Attributes._ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ implicit val mat = ActorMaterializer() @@ -26,7 +26,7 @@ class BidiFlowSpec extends AkkaSpec with ConversionCheckedTripleEquals { Flow[Long].map(x ⇒ x.toInt + 2).withAttributes(name("top")), Flow[String].map(ByteString(_)).withAttributes(name("bottom"))) - val bidiMat = BidiFlow.fromGraph(FlowGraph.create(Sink.head[Int]) { implicit b ⇒ + val bidiMat = BidiFlow.fromGraph(GraphDSL.create(Sink.head[Int]) { implicit b ⇒ s ⇒ Source.single(42) ~> s @@ -41,7 +41,7 @@ class BidiFlowSpec extends AkkaSpec with ConversionCheckedTripleEquals { "A BidiFlow" must { "work top/bottom in isolation" in { - val (top, bottom) = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Long], Sink.head[String])(Keep.both) { implicit b ⇒ + val (top, bottom) = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Long], Sink.head[String])(Keep.both) { implicit b ⇒ (st, sb) ⇒ val s = b.add(bidi) @@ -80,7 +80,7 @@ class BidiFlowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "materialize to its value" in { - val f = RunnableGraph.fromGraph(FlowGraph.create(bidiMat) { implicit b ⇒ + val f = RunnableGraph.fromGraph(GraphDSL.create(bidiMat) { implicit b ⇒ bidi ⇒ Flow[String].map(Integer.valueOf(_).toInt) <~> bidi <~> Flow[Long].map(x ⇒ ByteString(s"Hello $x")) ClosedShape @@ -89,7 +89,7 @@ class BidiFlowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "combine materialization values" in assertAllStagesStopped { - val left = Flow.fromGraph(FlowGraph.create(Sink.head[Int]) { implicit b ⇒ + val left = Flow.fromGraph(GraphDSL.create(Sink.head[Int]) { implicit b ⇒ sink ⇒ val bcast = b.add(Broadcast[Int](2)) val merge = b.add(Merge[Int](2)) @@ -99,7 +99,7 @@ class BidiFlowSpec extends AkkaSpec with ConversionCheckedTripleEquals { flow ~> merge FlowShape(flow.inlet, merge.out) }) - val right = Flow.fromGraph(FlowGraph.create(Sink.head[immutable.Seq[Long]]) { implicit b ⇒ + val right = Flow.fromGraph(GraphDSL.create(Sink.head[immutable.Seq[Long]]) { implicit b ⇒ sink ⇒ val flow = b.add(Flow[Long].grouped(10)) flow ~> sink diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowGraphCompileSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowGraphCompileSpec.scala index 20ee5ef0c6..2065576573 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowGraphCompileSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowGraphCompileSpec.scala @@ -40,9 +40,9 @@ class FlowGraphCompileSpec extends AkkaSpec { val out2 = Sink.head[String] "A Graph" should { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "build simple merge" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[String](2)) in1 ~> f1 ~> merge.in(0) in2 ~> f2 ~> merge.in(1) @@ -52,7 +52,7 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build simple broadcast" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[String](2)) in1 ~> f1 ~> bcast.in bcast.out(0) ~> f2 ~> out1 @@ -62,7 +62,7 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build simple balance" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val balance = b.add(Balance[String](2)) in1 ~> f1 ~> balance.in balance.out(0) ~> f2 ~> out1 @@ -72,7 +72,7 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build simple merge - broadcast" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[String](2)) val bcast = b.add(Broadcast[String](2)) in1 ~> f1 ~> merge.in(0) @@ -85,8 +85,8 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build simple merge - broadcast with implicits" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val merge = b.add(Merge[String](2)) val bcast = b.add(Broadcast[String](2)) b.add(in1) ~> f1 ~> merge.in(0) @@ -110,7 +110,7 @@ class FlowGraphCompileSpec extends AkkaSpec { "detect cycle in " in { pending // FIXME needs cycle detection capability intercept[IllegalArgumentException] { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[String](2)) val bcast1 = b.add(Broadcast[String](2)) val bcast2 = b.add(Broadcast[String](2)) @@ -128,12 +128,12 @@ class FlowGraphCompileSpec extends AkkaSpec { } "express complex topologies in a readable way" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[String](2)) val bcast1 = b.add(Broadcast[String](2)) val bcast2 = b.add(Broadcast[String](2)) val feedbackLoopBuffer = Flow[String].buffer(10, OverflowStrategy.dropBuffer) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ b.add(in1) ~> f1 ~> merge ~> f2 ~> bcast1 ~> f3 ~> b.add(out1) bcast1 ~> feedbackLoopBuffer ~> bcast2 ~> f5 ~> merge bcast2 ~> f6 ~> b.add(out2) @@ -142,10 +142,10 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build broadcast - merge" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[String](2)) val merge = b.add(Merge[String](2)) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ in1 ~> f1 ~> bcast ~> f2 ~> merge ~> f3 ~> out1 bcast ~> f4 ~> merge ClosedShape @@ -154,7 +154,7 @@ class FlowGraphCompileSpec extends AkkaSpec { "build wikipedia Topological_sorting" in { // see https://en.wikipedia.org/wiki/Topological_sorting#mediaviewer/File:Directed_acyclic_graph.png - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val b3 = b.add(Broadcast[String](2)) val b7 = b.add(Broadcast[String](2)) val b11 = b.add(Broadcast[String](3)) @@ -169,7 +169,7 @@ class FlowGraphCompileSpec extends AkkaSpec { val out9 = Sink.publisher[String](false) val out10 = Sink.publisher[String](false) def f(s: String) = Flow[String].transform(op[String, String]).named(s) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ in7 ~> f("a") ~> b7 ~> f("b") ~> m11 ~> f("c") ~> b11 ~> f("d") ~> out2 b11 ~> f("e") ~> m9 ~> f("f") ~> out9 @@ -183,10 +183,10 @@ class FlowGraphCompileSpec extends AkkaSpec { } "make it optional to specify flows" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[String](2)) val bcast = b.add(Broadcast[String](2)) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ in1 ~> merge ~> bcast ~> out1 in2 ~> merge bcast ~> out2 @@ -195,11 +195,11 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build unzip - zip" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(Zip[Int, String]()) val unzip = b.add(Unzip[Int, String]()) val out = Sink.publisher[(Int, String)](false) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ Source(List(1 -> "a", 2 -> "b", 3 -> "c")) ~> unzip.in unzip.out0 ~> Flow[Int].map(_ * 2) ~> zip.in0 unzip.out1 ~> zip.in1 @@ -210,7 +210,7 @@ class FlowGraphCompileSpec extends AkkaSpec { "distinguish between input and output ports" in { intercept[IllegalArgumentException] { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(Zip[Int, String]()) val unzip = b.add(Unzip[Int, String]()) val wrongOut = Sink.publisher[(Int, Int)](false) @@ -227,8 +227,8 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build with variance" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val merge = b.add(Merge[Fruit](2)) Source[Fruit](apples) ~> Flow[Fruit] ~> merge.in(0) Source[Apple](apples) ~> Flow[Apple] ~> merge.in(1) @@ -238,8 +238,8 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build with variance when indices are not specified" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val fruitMerge = b.add(Merge[Fruit](2)) Source[Fruit](apples) ~> fruitMerge Source[Apple](apples) ~> fruitMerge @@ -271,7 +271,7 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build with implicits and variance" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ def appleSource = b.add(Source(TestPublisher.manualProbe[Apple]())) def fruitSource = b.add(Source(TestPublisher.manualProbe[Fruit]())) val outA = b add Sink(TestSubscriber.manualProbe[Fruit]()) @@ -279,7 +279,7 @@ class FlowGraphCompileSpec extends AkkaSpec { val merge = b add Merge[Fruit](11) val unzip = b add Unzip[Int, String]() val whatever = b add Sink.publisher[Any](false) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ b.add(Source[Fruit](apples)) ~> merge.in(0) appleSource ~> merge.in(1) appleSource ~> merge.in(2) @@ -308,32 +308,32 @@ class FlowGraphCompileSpec extends AkkaSpec { } "build with plain flow without junctions" in { - import FlowGraph.Implicits._ - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + import GraphDSL.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ in1 ~> f1 ~> out1 ClosedShape }).run() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ in1 ~> f1 ~> f2.to(out1) ClosedShape }).run() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ (in1 via f1) ~> f2 ~> out1 ClosedShape }).run() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ in1 ~> out1 ClosedShape }).run() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ in1 ~> (f1 to out1) ClosedShape }).run() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ (in1 via f1) ~> out1 ClosedShape }).run() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ (in1 via f1) ~> (f2 to out1) ClosedShape }).run() diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowJoinSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowJoinSpec.scala index 39c6c6e7f8..b2b12a5f1c 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowJoinSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowJoinSpec.scala @@ -24,8 +24,8 @@ class FlowJoinSpec extends AkkaSpec(ConfigFactory.parseString("akka.loglevel=INF val source = Source(0 to end) val probe = TestSubscriber.manualProbe[Seq[Int]]() - val flow1 = Flow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val flow1 = Flow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val merge = b.add(Merge[Int](2)) val broadcast = b.add(Broadcast[Int](2)) source ~> merge.in(0) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowSectionSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowSectionSpec.scala index 551f6bb3a9..64191a9040 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowSectionSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/FlowSectionSpec.scala @@ -33,8 +33,8 @@ class FlowSectionSpec extends AkkaSpec(FlowSectionSpec.config) { } "have a nested flow with a different dispatcher" in { - val flow = Flow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val flow = Flow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val bcast1 = b.add(Broadcast[Int](1)) val bcast2 = b.add(Broadcast[Int](1)) bcast1 ~> Flow[Int].map(sendThreadNameTo(testActor)) ~> bcast2.in @@ -51,16 +51,16 @@ class FlowSectionSpec extends AkkaSpec(FlowSectionSpec.config) { val probe1 = TestProbe() val probe2 = TestProbe() - val flow1 = Flow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val flow1 = Flow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val bcast1 = b.add(Broadcast[Int](1)) val bcast2 = b.add(Broadcast[Int](1)) bcast1 ~> Flow[Int].map(sendThreadNameTo(probe1.ref)) ~> bcast2.in FlowShape(bcast1.in, bcast2.out(0)) }).withAttributes(dispatcher("my-dispatcher1")) - val flow2 = Flow.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val flow2 = Flow.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val bcast1 = b.add(Broadcast[Int](1)) val bcast2 = b.add(Broadcast[Int](1)) bcast1 ~> flow1.via(Flow[Int].map(sendThreadNameTo(probe2.ref))) ~> bcast2.in diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBackedFlowSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBackedFlowSpec.scala index eb583fbe5d..8d31da600f 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBackedFlowSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBackedFlowSpec.scala @@ -12,8 +12,8 @@ import org.reactivestreams.Subscriber object GraphFlowSpec { val source1 = Source(0 to 3) - val partialGraph = FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + val partialGraph = GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val source2 = Source(4 to 9) val source3 = Source.empty[Int] val source4 = Source.empty[String] @@ -62,9 +62,9 @@ class GraphFlowSpec extends AkkaSpec { "work with a Source and Sink" in { val probe = TestSubscriber.manualProbe[Int]() - val flow = Flow.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val flow = Flow.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ FlowShape(partial.inlet, partial.outlet.map(_.toInt).outlet) }) @@ -76,7 +76,7 @@ class GraphFlowSpec extends AkkaSpec { "be transformable with a Pipe" in { val probe = TestSubscriber.manualProbe[Int]() - val flow = Flow.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val flow = Flow.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ FlowShape(partial.inlet, partial.outlet) }) @@ -88,12 +88,12 @@ class GraphFlowSpec extends AkkaSpec { "work with another GraphFlow" in { val probe = TestSubscriber.manualProbe[Int]() - val flow1 = Flow.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val flow1 = Flow.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ FlowShape(partial.inlet, partial.outlet) }) - val flow2 = Flow.fromGraph(FlowGraph.create(Flow[String].map(_.toInt)) { implicit b ⇒ + val flow2 = Flow.fromGraph(GraphDSL.create(Flow[String].map(_.toInt)) { implicit b ⇒ importFlow ⇒ FlowShape(importFlow.inlet, importFlow.outlet) }) @@ -106,12 +106,12 @@ class GraphFlowSpec extends AkkaSpec { "be reusable multiple times" in { val probe = TestSubscriber.manualProbe[Int]() - val flow = Flow.fromGraph(FlowGraph.create(Flow[Int].map(_ * 2)) { implicit b ⇒ + val flow = Flow.fromGraph(GraphDSL.create(Flow[Int].map(_ * 2)) { implicit b ⇒ importFlow ⇒ FlowShape(importFlow.inlet, importFlow.outlet) }) - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ Source(1 to 5) ~> flow ~> flow ~> Sink(probe) ClosedShape }).run() @@ -124,9 +124,9 @@ class GraphFlowSpec extends AkkaSpec { "work with a Sink" in { val probe = TestSubscriber.manualProbe[Int]() - val source = Source.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val source = Source.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ source1 ~> partial.inlet SourceShape(partial.outlet.map(_.toInt).outlet) }) @@ -149,9 +149,9 @@ class GraphFlowSpec extends AkkaSpec { val probe = TestSubscriber.manualProbe[Int]() - val source = Source.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val source = Source.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ source1 ~> partial.inlet SourceShape(partial.outlet) }) @@ -164,14 +164,14 @@ class GraphFlowSpec extends AkkaSpec { "work with an GraphFlow" in { val probe = TestSubscriber.manualProbe[Int]() - val source = Source.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val source = Source.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ source1 ~> partial.inlet SourceShape(partial.outlet) }) - val flow = Flow.fromGraph(FlowGraph.create(Flow[String].map(_.toInt)) { implicit b ⇒ + val flow = Flow.fromGraph(GraphDSL.create(Flow[String].map(_.toInt)) { implicit b ⇒ importFlow ⇒ FlowShape(importFlow.inlet, importFlow.outlet) }) @@ -184,15 +184,15 @@ class GraphFlowSpec extends AkkaSpec { "be reusable multiple times" in { val probe = TestSubscriber.manualProbe[Int]() - val source = Source.fromGraph(FlowGraph.create(Source(1 to 5)) { implicit b ⇒ + val source = Source.fromGraph(GraphDSL.create(Source(1 to 5)) { implicit b ⇒ s ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ SourceShape(s.outlet.map(_ * 2).outlet) }) - RunnableGraph.fromGraph(FlowGraph.create(source, source)(Keep.both) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(source, source)(Keep.both) { implicit b ⇒ (s1, s2) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val merge = b.add(Merge[Int](2)) s1.outlet ~> merge.in(0) merge.out ~> Sink(probe) @@ -208,9 +208,9 @@ class GraphFlowSpec extends AkkaSpec { "work with a Source" in { val probe = TestSubscriber.manualProbe[Int]() - val sink = Sink.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ partial.outlet.map(_.toInt) ~> Sink(probe) SinkShape(partial.inlet) }) @@ -224,7 +224,7 @@ class GraphFlowSpec extends AkkaSpec { val probe = TestSubscriber.manualProbe[Int]() val pubSink = Sink.publisher[Int](false) - val sink = Sink.fromGraph(FlowGraph.create(pubSink) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(pubSink) { implicit b ⇒ p ⇒ SinkShape(p.inlet) }) @@ -237,9 +237,9 @@ class GraphFlowSpec extends AkkaSpec { "be transformable with a Pipe" in { val probe = TestSubscriber.manualProbe[Int]() - val sink = Sink.fromGraph(FlowGraph.create(partialGraph, Flow[String].map(_.toInt))(Keep.both) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(partialGraph, Flow[String].map(_.toInt))(Keep.both) { implicit b ⇒ (partial, flow) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ flow.outlet ~> partial.inlet partial.outlet.map(_.toInt) ~> Sink(probe) SinkShape(flow.inlet) @@ -255,14 +255,14 @@ class GraphFlowSpec extends AkkaSpec { val probe = TestSubscriber.manualProbe[Int]() - val flow = Flow.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val flow = Flow.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ FlowShape(partial.inlet, partial.outlet) }) - val sink = Sink.fromGraph(FlowGraph.create(Flow[String].map(_.toInt)) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(Flow[String].map(_.toInt)) { implicit b ⇒ flow ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ flow.outlet ~> Sink(probe) SinkShape(flow.inlet) }) @@ -279,29 +279,29 @@ class GraphFlowSpec extends AkkaSpec { val inSource = Source.subscriber[Int] val outSink = Sink.publisher[Int](false) - val flow = Flow.fromGraph(FlowGraph.create(partialGraph) { implicit b ⇒ + val flow = Flow.fromGraph(GraphDSL.create(partialGraph) { implicit b ⇒ partial ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ FlowShape(partial.inlet, partial.outlet.map(_.toInt).outlet) }) - val source = Source.fromGraph(FlowGraph.create(Flow[Int].map(_.toString), inSource)(Keep.right) { implicit b ⇒ + val source = Source.fromGraph(GraphDSL.create(Flow[Int].map(_.toString), inSource)(Keep.right) { implicit b ⇒ (flow, src) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ src.outlet ~> flow.inlet SourceShape(flow.outlet) }) - val sink = Sink.fromGraph(FlowGraph.create(Flow[String].map(_.toInt), outSink)(Keep.right) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(Flow[String].map(_.toInt), outSink)(Keep.right) { implicit b ⇒ (flow, snk) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ flow.outlet ~> snk.inlet SinkShape(flow.inlet) }) - val (m1, m2, m3) = RunnableGraph.fromGraph(FlowGraph.create(source, flow, sink)(Tuple3.apply) { implicit b ⇒ + val (m1, m2, m3) = RunnableGraph.fromGraph(GraphDSL.create(source, flow, sink)(Tuple3.apply) { implicit b ⇒ (src, f, snk) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ src.outlet.map(_.toInt) ~> f.inlet f.outlet.map(_.toString) ~> snk.inlet ClosedShape @@ -320,19 +320,19 @@ class GraphFlowSpec extends AkkaSpec { val inSource = Source.subscriber[Int] val outSink = Sink.publisher[Int](false) - val source = Source.fromGraph(FlowGraph.create(inSource) { implicit b ⇒ + val source = Source.fromGraph(GraphDSL.create(inSource) { implicit b ⇒ src ⇒ SourceShape(src.outlet) }) - val sink = Sink.fromGraph(FlowGraph.create(outSink) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(outSink) { implicit b ⇒ snk ⇒ SinkShape(snk.inlet) }) - val (m1, m2) = RunnableGraph.fromGraph(FlowGraph.create(source, sink)(Keep.both) { implicit b ⇒ + val (m1, m2) = RunnableGraph.fromGraph(GraphDSL.create(source, sink)(Keep.both) { implicit b ⇒ (src, snk) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ src.outlet ~> snk.inlet ClosedShape }).run() diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBalanceSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBalanceSpec.scala index 006a3db8c1..42d563f148 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBalanceSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBalanceSpec.scala @@ -17,13 +17,13 @@ class GraphBalanceSpec extends AkkaSpec { implicit val materializer = ActorMaterializer(settings) "A balance" must { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "balance between subscribers which signal demand" in assertAllStagesStopped { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val balance = b.add(Balance[Int](2)) Source(List(1, 2, 3)) ~> balance.in balance.out(0) ~> Sink(c1) @@ -47,7 +47,7 @@ class GraphBalanceSpec extends AkkaSpec { "support waiting for demand from all downstream subscriptions" in { val s1 = TestSubscriber.manualProbe[Int]() - val p2 = RunnableGraph.fromGraph(FlowGraph.create(Sink.publisher[Int](false)) { implicit b ⇒ + val p2 = RunnableGraph.fromGraph(GraphDSL.create(Sink.publisher[Int](false)) { implicit b ⇒ p2Sink ⇒ val balance = b.add(Balance[Int](2, waitForAllDownstreams = true)) Source(List(1, 2, 3)) ~> balance.in @@ -78,7 +78,7 @@ class GraphBalanceSpec extends AkkaSpec { "support waiting for demand from all non-cancelled downstream subscriptions" in assertAllStagesStopped { val s1 = TestSubscriber.manualProbe[Int]() - val (p2, p3) = RunnableGraph.fromGraph(FlowGraph.create(Sink.publisher[Int](false), Sink.publisher[Int](false))(Keep.both) { implicit b ⇒ + val (p2, p3) = RunnableGraph.fromGraph(GraphDSL.create(Sink.publisher[Int](false), Sink.publisher[Int](false))(Keep.both) { implicit b ⇒ (p2Sink, p3Sink) ⇒ val balance = b.add(Balance[Int](3, waitForAllDownstreams = true)) Source(List(1, 2, 3)) ~> balance.in @@ -113,7 +113,7 @@ class GraphBalanceSpec extends AkkaSpec { "work with 5-way balance" in { val sink = Sink.head[Seq[Int]] - val (s1, s2, s3, s4, s5) = RunnableGraph.fromGraph(FlowGraph.create(sink, sink, sink, sink, sink)(Tuple5.apply) { + val (s1, s2, s3, s4, s5) = RunnableGraph.fromGraph(GraphDSL.create(sink, sink, sink, sink, sink)(Tuple5.apply) { implicit b ⇒ (f1, f2, f3, f4, f5) ⇒ val balance = b.add(Balance[Int](5, waitForAllDownstreams = true)) @@ -133,7 +133,7 @@ class GraphBalanceSpec extends AkkaSpec { val numElementsForSink = 10000 val outputs = Sink.fold[Int, Int](0)(_ + _) - val results = RunnableGraph.fromGraph(FlowGraph.create(outputs, outputs, outputs)(List(_, _, _)) { implicit b ⇒ + val results = RunnableGraph.fromGraph(GraphDSL.create(outputs, outputs, outputs)(List(_, _, _)) { implicit b ⇒ (o1, o2, o3) ⇒ val balance = b.add(Balance[Int](3, waitForAllDownstreams = true)) Source.repeat(1).take(numElementsForSink * 3) ~> balance.in @@ -153,7 +153,7 @@ class GraphBalanceSpec extends AkkaSpec { "fairly balance between three outputs" in { val probe = TestSink.probe[Int] - val (p1, p2, p3) = RunnableGraph.fromGraph(FlowGraph.create(probe, probe, probe)(Tuple3.apply) { implicit b ⇒ + val (p1, p2, p3) = RunnableGraph.fromGraph(GraphDSL.create(probe, probe, probe)(Tuple3.apply) { implicit b ⇒ (o1, o2, o3) ⇒ val balance = b.add(Balance[Int](3)) Source(1 to 7) ~> balance.in @@ -180,7 +180,7 @@ class GraphBalanceSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val balance = b.add(Balance[Int](2)) Source(List(1, 2, 3)) ~> balance.in balance.out(0) ~> Sink(c1) @@ -202,7 +202,7 @@ class GraphBalanceSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val balance = b.add(Balance[Int](2)) Source(List(1, 2, 3)) ~> balance.in balance.out(0) ~> Sink(c1) @@ -225,7 +225,7 @@ class GraphBalanceSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val balance = b.add(Balance[Int](2)) Source(p1.getPublisher) ~> balance.in balance.out(0) ~> Sink(c1) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBroadcastSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBroadcastSpec.scala index 9b130d5e94..f70c77de49 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBroadcastSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphBroadcastSpec.scala @@ -17,13 +17,13 @@ class GraphBroadcastSpec extends AkkaSpec { implicit val materializer = ActorMaterializer(settings) "A broadcast" must { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "broadcast to other subscriber" in assertAllStagesStopped { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](2)) Source(List(1, 2, 3)) ~> bcast.in bcast.out(0) ~> Flow[Int].buffer(16, OverflowStrategy.backpressure) ~> Sink(c1) @@ -53,7 +53,7 @@ class GraphBroadcastSpec extends AkkaSpec { val headSink = Sink.head[Seq[Int]] import system.dispatcher - val result = RunnableGraph.fromGraph(FlowGraph.create( + val result = RunnableGraph.fromGraph(GraphDSL.create( headSink, headSink, headSink, @@ -84,7 +84,7 @@ class GraphBroadcastSpec extends AkkaSpec { (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22) ⇒ Future.sequence(List(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20, f21, f22)) - val result = RunnableGraph.fromGraph(FlowGraph.create( + val result = RunnableGraph.fromGraph(GraphDSL.create( headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, @@ -126,7 +126,7 @@ class GraphBroadcastSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](2)) Source(List(1, 2, 3)) ~> bcast.in bcast.out(0) ~> Flow[Int] ~> Sink(c1) @@ -148,7 +148,7 @@ class GraphBroadcastSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](2)) Source(List(1, 2, 3)) ~> bcast.in bcast.out(0) ~> Flow[Int].named("identity-a") ~> Sink(c1) @@ -171,7 +171,7 @@ class GraphBroadcastSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](2)) Source(p1.getPublisher) ~> bcast.in bcast.out(0) ~> Flow[Int] ~> Sink(c1) @@ -200,7 +200,7 @@ class GraphBroadcastSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[Int]() - val sink = Sink.fromGraph(FlowGraph.create() { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](2)) bcast.out(0) ~> Sink(c1) bcast.out(1) ~> Sink(c2) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphConcatSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphConcatSpec.scala index 6742f7a778..bea3be6b91 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphConcatSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphConcatSpec.scala @@ -15,7 +15,7 @@ class GraphConcatSpec extends TwoStreamsSetup { override type Outputs = Int - override def fixture(b: FlowGraph.Builder[_]): Fixture = new Fixture(b) { + override def fixture(b: GraphDSL.Builder[_]): Fixture = new Fixture(b) { val concat = b add Concat[Outputs]() override def left: Inlet[Outputs] = concat.in(0) @@ -25,12 +25,12 @@ class GraphConcatSpec extends TwoStreamsSetup { } "Concat" must { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "work in the happy case" in assertAllStagesStopped { val probe = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val concat1 = b add Concat[Int]() val concat2 = b add Concat[Int]() @@ -141,7 +141,7 @@ class GraphConcatSpec extends TwoStreamsSetup { val promise = Promise[Int]() val subscriber = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val concat = b add Concat[Int]() Source(List(1, 2, 3)) ~> concat.in(0) Source(promise.future) ~> concat.in(1) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMatValueSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMatValueSpec.scala index 3431f7b257..700f585122 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMatValueSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMatValueSpec.scala @@ -17,7 +17,7 @@ class GraphMatValueSpec extends AkkaSpec { implicit val materializer = ActorMaterializer(settings) - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "A Graph with materialized value" must { @@ -25,7 +25,7 @@ class GraphMatValueSpec extends AkkaSpec { "expose the materialized value as source" in { val sub = TestSubscriber.manualProbe[Int]() - val f = RunnableGraph.fromGraph(FlowGraph.create(foldSink) { implicit b ⇒ + val f = RunnableGraph.fromGraph(GraphDSL.create(foldSink) { implicit b ⇒ fold ⇒ Source(1 to 10) ~> fold b.materializedValue.mapAsync(4)(identity) ~> Sink(sub) @@ -42,7 +42,7 @@ class GraphMatValueSpec extends AkkaSpec { "expose the materialized value as source multiple times" in { val sub = TestSubscriber.manualProbe[Int]() - val f = RunnableGraph.fromGraph(FlowGraph.create(foldSink) { implicit b ⇒ + val f = RunnableGraph.fromGraph(GraphDSL.create(foldSink) { implicit b ⇒ fold ⇒ val zip = b.add(ZipWith[Int, Int, Int](_ + _)) Source(1 to 10) ~> fold @@ -61,7 +61,7 @@ class GraphMatValueSpec extends AkkaSpec { } // Exposes the materialized value as a stream value - val foldFeedbackSource: Source[Future[Int], Future[Int]] = Source.fromGraph(FlowGraph.create(foldSink) { implicit b ⇒ + val foldFeedbackSource: Source[Future[Int], Future[Int]] = Source.fromGraph(GraphDSL.create(foldSink) { implicit b ⇒ fold ⇒ Source(1 to 10) ~> fold SourceShape(b.materializedValue) @@ -79,7 +79,7 @@ class GraphMatValueSpec extends AkkaSpec { } "work properly with nesting and reusing" in { - val compositeSource1 = Source.fromGraph(FlowGraph.create(foldFeedbackSource, foldFeedbackSource)(Keep.both) { implicit b ⇒ + val compositeSource1 = Source.fromGraph(GraphDSL.create(foldFeedbackSource, foldFeedbackSource)(Keep.both) { implicit b ⇒ (s1, s2) ⇒ val zip = b.add(ZipWith[Int, Int, Int](_ + _)) @@ -88,7 +88,7 @@ class GraphMatValueSpec extends AkkaSpec { SourceShape(zip.out) }) - val compositeSource2 = Source.fromGraph(FlowGraph.create(compositeSource1, compositeSource1)(Keep.both) { implicit b ⇒ + val compositeSource2 = Source.fromGraph(GraphDSL.create(compositeSource1, compositeSource1)(Keep.both) { implicit b ⇒ (s1, s2) ⇒ val zip = b.add(ZipWith[Int, Int, Int](_ + _)) s1.outlet ~> zip.in0 diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergePreferredSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergePreferredSpec.scala index 6acb3625e2..8b0685adfc 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergePreferredSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergePreferredSpec.scala @@ -10,11 +10,11 @@ import scala.concurrent.Await import scala.concurrent.duration._ class GraphMergePreferredSpec extends TwoStreamsSetup { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ override type Outputs = Int - override def fixture(b: FlowGraph.Builder[_]): Fixture = new Fixture(b) { + override def fixture(b: GraphDSL.Builder[_]): Fixture = new Fixture(b) { val merge = b.add(MergePreferred[Outputs](1)) override def left: Inlet[Outputs] = merge.preferred @@ -32,7 +32,7 @@ class GraphMergePreferredSpec extends TwoStreamsSetup { val preferred = Source(Stream.fill(numElements)(1)) val aux = Source(Stream.fill(numElements)(2)) - val result = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Seq[Int]]) { implicit b ⇒ + val result = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Seq[Int]]) { implicit b ⇒ sink ⇒ val merge = b.add(MergePreferred[Int](3)) preferred ~> merge.preferred @@ -48,7 +48,7 @@ class GraphMergePreferredSpec extends TwoStreamsSetup { } "eventually pass through all elements" in { - val result = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Seq[Int]]) { implicit b ⇒ + val result = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Seq[Int]]) { implicit b ⇒ sink ⇒ val merge = b.add(MergePreferred[Int](3)) Source(1 to 100) ~> merge.preferred @@ -67,7 +67,7 @@ class GraphMergePreferredSpec extends TwoStreamsSetup { val s = Source(0 to 3) (the[IllegalArgumentException] thrownBy { - val g = RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(MergePreferred[Int](1)) s ~> merge.preferred diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergeSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergeSpec.scala index ecd67dd86f..b2cee7eb71 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergeSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphMergeSpec.scala @@ -11,11 +11,11 @@ import akka.stream.testkit._ import akka.stream.testkit.Utils._ class GraphMergeSpec extends TwoStreamsSetup { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ override type Outputs = Int - override def fixture(b: FlowGraph.Builder[_]): Fixture = new Fixture(b) { + override def fixture(b: GraphDSL.Builder[_]): Fixture = new Fixture(b) { val merge = b add Merge[Outputs](2) override def left: Inlet[Outputs] = merge.in(0) @@ -33,7 +33,7 @@ class GraphMergeSpec extends TwoStreamsSetup { val source3 = Source(List[Int]()) val probe = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val m1 = b.add(Merge[Int](2)) val m2 = b.add(Merge[Int](2)) @@ -68,7 +68,7 @@ class GraphMergeSpec extends TwoStreamsSetup { val probe = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[Int](6)) source1 ~> merge.in(0) @@ -154,7 +154,7 @@ class GraphMergeSpec extends TwoStreamsSetup { val src1 = Source.subscriber[Int] val src2 = Source.subscriber[Int] - val (graphSubscriber1, graphSubscriber2) = RunnableGraph.fromGraph(FlowGraph.create(src1, src2)((_, _)) { implicit b ⇒ + val (graphSubscriber1, graphSubscriber2) = RunnableGraph.fromGraph(GraphDSL.create(src1, src2)((_, _)) { implicit b ⇒ (s1, s2) ⇒ val merge = b.add(Merge[Int](2)) s1.outlet ~> merge.in(0) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphOpsIntegrationSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphOpsIntegrationSpec.scala index a9cd9a193f..64111b714a 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphOpsIntegrationSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphOpsIntegrationSpec.scala @@ -9,7 +9,7 @@ import akka.util.ByteString import org.scalactic.ConversionCheckedTripleEquals object GraphOpsIntegrationSpec { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ object Shuffle { @@ -30,7 +30,7 @@ object GraphOpsIntegrationSpec { } def apply[In, Out](pipeline: Flow[In, Out, _]): Graph[ShufflePorts[In, Out], Unit] = { - FlowGraph.create() { implicit b ⇒ + GraphDSL.create() { implicit b ⇒ val merge = b.add(Merge[In](2)) val balance = b.add(Balance[Out](2)) merge.out ~> pipeline ~> balance.in @@ -44,7 +44,7 @@ object GraphOpsIntegrationSpec { class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEquals { import akka.stream.scaladsl.GraphOpsIntegrationSpec._ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val settings = ActorMaterializerSettings(system) .withInputBuffer(initialSize = 2, maxSize = 16) @@ -54,7 +54,7 @@ class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEqual "FlowGraphs" must { "support broadcast - merge layouts" in { - val resultFuture = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Seq[Int]]) { implicit b ⇒ + val resultFuture = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Seq[Int]]) { implicit b ⇒ (sink) ⇒ val bcast = b.add(Broadcast[Int](2)) val merge = b.add(Merge[Int](2)) @@ -71,7 +71,7 @@ class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEqual "support balance - merge (parallelization) layouts" in { val elements = 0 to 10 - val out = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Seq[Int]]) { implicit b ⇒ + val out = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Seq[Int]]) { implicit b ⇒ (sink) ⇒ val balance = b.add(Balance[Int](5)) val merge = b.add(Merge[Int](5)) @@ -92,7 +92,7 @@ class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEqual // see https://en.wikipedia.org/wiki/Topological_sorting#mediaviewer/File:Directed_acyclic_graph.png val seqSink = Sink.head[Seq[Int]] - val (resultFuture2, resultFuture9, resultFuture10) = RunnableGraph.fromGraph(FlowGraph.create(seqSink, seqSink, seqSink)(Tuple3.apply) { implicit b ⇒ + val (resultFuture2, resultFuture9, resultFuture10) = RunnableGraph.fromGraph(GraphDSL.create(seqSink, seqSink, seqSink)(Tuple3.apply) { implicit b ⇒ (sink2, sink9, sink10) ⇒ val b3 = b.add(Broadcast[Int](2)) val b7 = b.add(Broadcast[Int](2)) @@ -139,7 +139,7 @@ class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEqual "allow adding of flows to sources and sinks to flows" in { - val resultFuture = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Seq[Int]]) { implicit b ⇒ + val resultFuture = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Seq[Int]]) { implicit b ⇒ (sink) ⇒ val bcast = b.add(Broadcast[Int](2)) val merge = b.add(Merge[Int](2)) @@ -158,7 +158,7 @@ class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEqual val p = Source(List(1, 2, 3)).runWith(Sink.publisher(false)) val s = TestSubscriber.manualProbe[Int] val flow = Flow[Int].map(_ * 2) - RunnableGraph.fromGraph(FlowGraph.create() { implicit builder ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit builder ⇒ Source(p) ~> flow ~> Sink(s) ClosedShape }).run() @@ -173,7 +173,7 @@ class GraphOpsIntegrationSpec extends AkkaSpec with ConversionCheckedTripleEqual "be possible to use as lego bricks" in { val shuffler = Shuffle(Flow[Int].map(_ + 1)) - val f: Future[Seq[Int]] = RunnableGraph.fromGraph(FlowGraph.create(shuffler, shuffler, shuffler, Sink.head[Seq[Int]])((_, _, _, fut) ⇒ fut) { implicit b ⇒ + val f: Future[Seq[Int]] = RunnableGraph.fromGraph(GraphDSL.create(shuffler, shuffler, shuffler, Sink.head[Seq[Int]])((_, _, _, fut) ⇒ fut) { implicit b ⇒ (s1, s2, s3, sink) ⇒ val merge = b.add(Merge[Int](2)) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphPartialSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphPartialSpec.scala index fb71aa5480..5a0f96c267 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphPartialSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphPartialSpec.scala @@ -7,7 +7,7 @@ import scala.concurrent.{ Await, Future } import scala.concurrent.duration._ class GraphPartialSpec extends AkkaSpec { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val settings = ActorMaterializerSettings(system) .withInputBuffer(initialSize = 2, maxSize = 16) @@ -15,10 +15,10 @@ class GraphPartialSpec extends AkkaSpec { implicit val materializer = ActorMaterializer(settings) "FlowFlowGraph.partial" must { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "be able to build and reuse simple partial graphs" in { - val doubler = FlowGraph.create() { implicit b ⇒ + val doubler = GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](2)) val zip = b.add(ZipWith((a: Int, b: Int) ⇒ a + b)) @@ -27,7 +27,7 @@ class GraphPartialSpec extends AkkaSpec { FlowShape(bcast.in, zip.out) } - val (_, _, result) = RunnableGraph.fromGraph(FlowGraph.create(doubler, doubler, Sink.head[Seq[Int]])(Tuple3.apply) { implicit b ⇒ + val (_, _, result) = RunnableGraph.fromGraph(GraphDSL.create(doubler, doubler, Sink.head[Seq[Int]])(Tuple3.apply) { implicit b ⇒ (d1, d2, sink) ⇒ Source(List(1, 2, 3)) ~> d1.inlet d1.outlet ~> d2.inlet @@ -39,7 +39,7 @@ class GraphPartialSpec extends AkkaSpec { } "be able to build and reuse simple materializing partial graphs" in { - val doubler = FlowGraph.create(Sink.head[Seq[Int]]) { implicit b ⇒ + val doubler = GraphDSL.create(Sink.head[Seq[Int]]) { implicit b ⇒ sink ⇒ val bcast = b.add(Broadcast[Int](3)) val zip = b.add(ZipWith((a: Int, b: Int) ⇒ a + b)) @@ -50,7 +50,7 @@ class GraphPartialSpec extends AkkaSpec { FlowShape(bcast.in, zip.out) } - val (sub1, sub2, result) = RunnableGraph.fromGraph(FlowGraph.create(doubler, doubler, Sink.head[Seq[Int]])(Tuple3.apply) { implicit b ⇒ + val (sub1, sub2, result) = RunnableGraph.fromGraph(GraphDSL.create(doubler, doubler, Sink.head[Seq[Int]])(Tuple3.apply) { implicit b ⇒ (d1, d2, sink) ⇒ Source(List(1, 2, 3)) ~> d1.inlet d1.outlet ~> d2.inlet @@ -66,7 +66,7 @@ class GraphPartialSpec extends AkkaSpec { "be able to build and reuse complex materializing partial graphs" in { val summer = Sink.fold[Int, Int](0)(_ + _) - val doubler = FlowGraph.create(summer, summer)(Tuple2.apply) { implicit b ⇒ + val doubler = GraphDSL.create(summer, summer)(Tuple2.apply) { implicit b ⇒ (s1, s2) ⇒ val bcast = b.add(Broadcast[Int](3)) val bcast2 = b.add(Broadcast[Int](2)) @@ -82,7 +82,7 @@ class GraphPartialSpec extends AkkaSpec { FlowShape(bcast.in, bcast2.out(1)) } - val (sub1, sub2, result) = RunnableGraph.fromGraph(FlowGraph.create(doubler, doubler, Sink.head[Seq[Int]])(Tuple3.apply) { implicit b ⇒ + val (sub1, sub2, result) = RunnableGraph.fromGraph(GraphDSL.create(doubler, doubler, Sink.head[Seq[Int]])(Tuple3.apply) { implicit b ⇒ (d1, d2, sink) ⇒ Source(List(1, 2, 3)) ~> d1.inlet d1.outlet ~> d2.inlet @@ -98,14 +98,14 @@ class GraphPartialSpec extends AkkaSpec { } "be able to expose the ports of imported graphs" in { - val p = FlowGraph.create(Flow[Int].map(_ + 1)) { implicit b ⇒ + val p = GraphDSL.create(Flow[Int].map(_ + 1)) { implicit b ⇒ flow ⇒ FlowShape(flow.inlet, flow.outlet) } - val fut = RunnableGraph.fromGraph(FlowGraph.create(Sink.head[Int], p)(Keep.left) { implicit b ⇒ + val fut = RunnableGraph.fromGraph(GraphDSL.create(Sink.head[Int], p)(Keep.left) { implicit b ⇒ (sink, flow) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ Source.single(0) ~> flow.inlet flow.outlet ~> sink.inlet ClosedShape diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipSpec.scala index 677494573a..bb7c6329b1 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipSpec.scala @@ -17,13 +17,13 @@ class GraphUnzipSpec extends AkkaSpec { implicit val materializer = ActorMaterializer(settings) "A unzip" must { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ "unzip to two subscribers" in assertAllStagesStopped { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(Unzip[Int, String]()) Source(List(1 -> "a", 2 -> "b", 3 -> "c")) ~> unzip.in unzip.out1 ~> Flow[String].buffer(16, OverflowStrategy.backpressure) ~> Sink(c2) @@ -53,7 +53,7 @@ class GraphUnzipSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(Unzip[Int, String]()) Source(List(1 -> "a", 2 -> "b", 3 -> "c")) ~> unzip.in unzip.out0 ~> Sink(c1) @@ -75,7 +75,7 @@ class GraphUnzipSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(Unzip[Int, String]()) Source(List(1 -> "a", 2 -> "b", 3 -> "c")) ~> unzip.in unzip.out0 ~> Sink(c1) @@ -98,7 +98,7 @@ class GraphUnzipSpec extends AkkaSpec { val c1 = TestSubscriber.manualProbe[Int]() val c2 = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(Unzip[Int, String]()) Source(p1.getPublisher) ~> unzip.in unzip.out0 ~> Sink(c1) @@ -125,7 +125,7 @@ class GraphUnzipSpec extends AkkaSpec { "work with zip" in assertAllStagesStopped { val c1 = TestSubscriber.manualProbe[(Int, String)]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(Zip[Int, String]()) val unzip = b.add(Unzip[Int, String]()) Source(List(1 -> "a", 2 -> "b", 3 -> "c")) ~> unzip.in diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipWithSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipWithSpec.scala index 5dac2ad328..43d3715fe0 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipWithSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphUnzipWithSpec.scala @@ -14,7 +14,7 @@ import scala.util.control.NoStackTrace class GraphUnzipWithSpec extends AkkaSpec { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val settings = ActorMaterializerSettings(system) .withInputBuffer(initialSize = 2, maxSize = 16) @@ -26,7 +26,7 @@ class GraphUnzipWithSpec extends AkkaSpec { type LeftOutput = Int type RightOutput = String - abstract class Fixture(b: FlowGraph.Builder[_]) { + abstract class Fixture(b: GraphDSL.Builder[_]) { def in: Inlet[Int] def left: Outlet[LeftOutput] def right: Outlet[RightOutput] @@ -34,7 +34,7 @@ class GraphUnzipWithSpec extends AkkaSpec { val f: (Int ⇒ (Int, String)) = b ⇒ (b + b, b + "+" + b) - def fixture(b: FlowGraph.Builder[_]): Fixture = new Fixture(b) { + def fixture(b: GraphDSL.Builder[_]): Fixture = new Fixture(b) { val unzip = b.add(UnzipWith[Int, Int, String](f)) override def in: Inlet[Int] = unzip.in @@ -48,7 +48,7 @@ class GraphUnzipWithSpec extends AkkaSpec { val leftSubscriber = TestSubscriber.probe[LeftOutput]() val rightSubscriber = TestSubscriber.probe[RightOutput]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val f = fixture(b) Source(p) ~> f.in @@ -97,7 +97,7 @@ class GraphUnzipWithSpec extends AkkaSpec { val leftProbe = TestSubscriber.manualProbe[LeftOutput]() val rightProbe = TestSubscriber.manualProbe[RightOutput]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(UnzipWith(f)) Source(1 to 4) ~> unzip.in @@ -147,7 +147,7 @@ class GraphUnzipWithSpec extends AkkaSpec { val leftProbe = TestSubscriber.manualProbe[LeftOutput]() val rightProbe = TestSubscriber.manualProbe[RightOutput]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(UnzipWith[Int, Int, String]((b: Int) ⇒ (1 / b, 1 + "/" + b))) Source(-2 to 2) ~> unzip.in @@ -192,7 +192,7 @@ class GraphUnzipWithSpec extends AkkaSpec { case class Person(name: String, surname: String, int: Int) - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val unzip = b.add(UnzipWith((a: Person) ⇒ Person.unapply(a).get)) Source.single(Person("Caplin", "Capybara", 3)) ~> unzip.in @@ -228,7 +228,7 @@ class GraphUnzipWithSpec extends AkkaSpec { val probe15 = TestSubscriber.manualProbe[String]() val probe19 = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val split20 = (a: (List[Int])) ⇒ (a(0), a(0).toString, diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipSpec.scala index ec1da3f1de..0d253b375f 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipSpec.scala @@ -11,11 +11,11 @@ import scala.concurrent.Await import scala.concurrent.duration._ class GraphZipSpec extends TwoStreamsSetup { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ override type Outputs = (Int, Int) - override def fixture(b: FlowGraph.Builder[_]): Fixture = new Fixture(b) { + override def fixture(b: GraphDSL.Builder[_]): Fixture = new Fixture(b) { val zip = b.add(Zip[Int, Int]()) override def left: Inlet[Int] = zip.in0 @@ -28,7 +28,7 @@ class GraphZipSpec extends TwoStreamsSetup { "work in the happy case" in assertAllStagesStopped { val probe = TestSubscriber.manualProbe[(Int, String)]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(Zip[Int, String]()) Source(1 to 4) ~> zip.in0 @@ -57,7 +57,7 @@ class GraphZipSpec extends TwoStreamsSetup { val upstream1 = TestPublisher.probe[Int]() val upstream2 = TestPublisher.probe[String]() - val completed = RunnableGraph.fromGraph(FlowGraph.create(Sink.ignore) { implicit b ⇒ + val completed = RunnableGraph.fromGraph(GraphDSL.create(Sink.ignore) { implicit b ⇒ out ⇒ val zip = b.add(Zip[Int, String]()) @@ -83,7 +83,7 @@ class GraphZipSpec extends TwoStreamsSetup { val upstream2 = TestPublisher.probe[String]() val downstream = TestSubscriber.probe[(Int, String)]() - RunnableGraph.fromGraph(FlowGraph.create(Sink(downstream)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(Sink(downstream)) { implicit b ⇒ out ⇒ val zip = b.add(Zip[Int, String]()) @@ -110,7 +110,7 @@ class GraphZipSpec extends TwoStreamsSetup { val upstream2 = TestPublisher.probe[String]() val downstream = TestSubscriber.probe[(Int, String)]() - RunnableGraph.fromGraph(FlowGraph.create(Sink(downstream)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(Sink(downstream)) { implicit b ⇒ out ⇒ val zip = b.add(Zip[Int, String]()) @@ -139,7 +139,7 @@ class GraphZipSpec extends TwoStreamsSetup { val upstream2 = TestPublisher.probe[String]() val downstream = TestSubscriber.probe[(Int, String)]() - RunnableGraph.fromGraph(FlowGraph.create(Sink(downstream)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(Sink(downstream)) { implicit b ⇒ out ⇒ val zip = b.add(Zip[Int, String]()) @@ -169,7 +169,7 @@ class GraphZipSpec extends TwoStreamsSetup { val upstream2 = TestPublisher.probe[String]() val downstream = TestSubscriber.probe[(Int, String)]() - RunnableGraph.fromGraph(FlowGraph.create(Sink(downstream)) { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create(Sink(downstream)) { implicit b ⇒ out ⇒ val zip = b.add(Zip[Int, String]()) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipWithSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipWithSpec.scala index a693feed40..da7d6b8f61 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipWithSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/GraphZipWithSpec.scala @@ -5,11 +5,11 @@ import scala.concurrent.duration._ import akka.stream._ class GraphZipWithSpec extends TwoStreamsSetup { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ override type Outputs = Int - override def fixture(b: FlowGraph.Builder[_]): Fixture = new Fixture(b) { + override def fixture(b: GraphDSL.Builder[_]): Fixture = new Fixture(b) { val zip = b.add(ZipWith((_: Int) + (_: Int))) override def left: Inlet[Int] = zip.in0 override def right: Inlet[Int] = zip.in1 @@ -21,7 +21,7 @@ class GraphZipWithSpec extends TwoStreamsSetup { "work in the happy case" in { val probe = TestSubscriber.manualProbe[Outputs]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(ZipWith((_: Int) + (_: Int))) Source(1 to 4) ~> zip.in0 Source(10 to 40 by 10) ~> zip.in1 @@ -48,7 +48,7 @@ class GraphZipWithSpec extends TwoStreamsSetup { "work in the sad case" in { val probe = TestSubscriber.manualProbe[Outputs]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(ZipWith[Int, Int, Int]((_: Int) / (_: Int))) Source(1 to 4) ~> zip.in0 @@ -111,7 +111,7 @@ class GraphZipWithSpec extends TwoStreamsSetup { case class Person(name: String, surname: String, int: Int) - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val zip = b.add(ZipWith(Person.apply _)) Source.single("Caplin") ~> zip.in0 @@ -134,7 +134,7 @@ class GraphZipWithSpec extends TwoStreamsSetup { "work with up to 22 inputs" in { val probe = TestSubscriber.manualProbe[String]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val sum19 = (v1: Int, v2: String, v3: Int, v4: String, v5: Int, v6: String, v7: Int, v8: String, v9: Int, v10: String, v11: Int, v12: String, v13: Int, v14: String, v15: Int, v16: String, v17: Int, v18: String, v19: Int) ⇒ diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/PublisherSinkSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/PublisherSinkSpec.scala index b31847e4e9..a257f14460 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/PublisherSinkSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/PublisherSinkSpec.scala @@ -19,9 +19,9 @@ class PublisherSinkSpec extends AkkaSpec { "be unique when created twice" in assertAllStagesStopped { - val (pub1, pub2) = RunnableGraph.fromGraph(FlowGraph.create(Sink.publisher[Int](false), Sink.publisher[Int](false))(Keep.both) { implicit b ⇒ + val (pub1, pub2) = RunnableGraph.fromGraph(GraphDSL.create(Sink.publisher[Int](false), Sink.publisher[Int](false))(Keep.both) { implicit b ⇒ (p1, p2) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val bcast = b.add(Broadcast[Int](2)) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/ReverseArrowSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/ReverseArrowSpec.scala index 75da9d9253..1733f924ae 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/ReverseArrowSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/ReverseArrowSpec.scala @@ -7,7 +7,7 @@ import scala.concurrent.duration._ import org.scalactic.ConversionCheckedTripleEquals class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ implicit val mat = ActorMaterializer() val source = Source(List(1, 2, 3)) @@ -16,7 +16,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { "Reverse Arrows in the Graph DSL" must { "work from Inlets" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ s.inlet <~ source ClosedShape @@ -24,7 +24,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work from SinkShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ s <~ source ClosedShape @@ -33,7 +33,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { "work from Sink" in { val sub = TestSubscriber.manualProbe[Int] - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ Sink(sub) <~ source ClosedShape }).run() @@ -43,7 +43,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "not work from Outlets" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val o: Outlet[Int] = b.add(source).outlet "o <~ source" shouldNot compile sink <~ o @@ -52,7 +52,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "not work from SourceShape" in { - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ val o: SourceShape[Int] = b.add(source) "o <~ source" shouldNot compile sink <~ o @@ -65,7 +65,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work from FlowShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: FlowShape[Int, Int] = b.add(Flow[Int]) f <~ source @@ -75,7 +75,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work from UniformFanInShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: UniformFanInShape[Int, Int] = b.add(Merge[Int](1)) f <~ source @@ -85,7 +85,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work from UniformFanOutShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: UniformFanOutShape[Int, Int] = b.add(Broadcast[Int](1)) f <~ source @@ -95,7 +95,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work towards Outlets" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val o: Outlet[Int] = b.add(source).outlet s <~ o @@ -104,7 +104,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work towards SourceShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val o: SourceShape[Int] = b.add(source) s <~ o @@ -113,7 +113,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work towards Source" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ s <~ source ClosedShape @@ -121,7 +121,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work towards FlowShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: FlowShape[Int, Int] = b.add(Flow[Int]) s <~ f @@ -131,7 +131,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work towards UniformFanInShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: UniformFanInShape[Int, Int] = b.add(Merge[Int](1)) s <~ f @@ -141,7 +141,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "fail towards already full UniformFanInShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: UniformFanInShape[Int, Int] = b.add(Merge[Int](1)) val src = b.add(source) @@ -152,7 +152,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work towards UniformFanOutShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: UniformFanOutShape[Int, Int] = b.add(Broadcast[Int](1)) s <~ f @@ -162,7 +162,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "fail towards already full UniformFanOutShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ val f: UniformFanOutShape[Int, Int] = b.add(Broadcast[Int](1)) val src = b.add(source) @@ -173,7 +173,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work across a Flow" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ s <~ Flow[Int] <~ source ClosedShape @@ -181,7 +181,7 @@ class ReverseArrowSpec extends AkkaSpec with ConversionCheckedTripleEquals { } "work across a FlowShape" in { - Await.result(RunnableGraph.fromGraph(FlowGraph.create(sink) { implicit b ⇒ + Await.result(RunnableGraph.fromGraph(GraphDSL.create(sink) { implicit b ⇒ s ⇒ s <~ b.add(Flow[Int]) <~ source ClosedShape diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SinkSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SinkSpec.scala index b978a95265..54d138ac22 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SinkSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SinkSpec.scala @@ -9,7 +9,7 @@ import akka.stream.testkit._ class SinkSpec extends AkkaSpec { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ implicit val mat = ActorMaterializer() @@ -17,7 +17,7 @@ class SinkSpec extends AkkaSpec { "be composable without importing modules" in { val probes = Array.fill(3)(TestSubscriber.manualProbe[Int]) - val sink = Sink.fromGraph(FlowGraph.create() { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create() { implicit b ⇒ val bcast = b.add(Broadcast[Int](3)) for (i ← 0 to 2) bcast.out(i).filter(_ == i) ~> Sink(probes(i)) SinkShape(bcast.in) @@ -34,7 +34,7 @@ class SinkSpec extends AkkaSpec { "be composable with importing 1 module" in { val probes = Array.fill(3)(TestSubscriber.manualProbe[Int]) - val sink = Sink.fromGraph(FlowGraph.create(Sink(probes(0))) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(Sink(probes(0))) { implicit b ⇒ s0 ⇒ val bcast = b.add(Broadcast[Int](3)) bcast.out(0) ~> Flow[Int].filter(_ == 0) ~> s0.inlet @@ -53,7 +53,7 @@ class SinkSpec extends AkkaSpec { "be composable with importing 2 modules" in { val probes = Array.fill(3)(TestSubscriber.manualProbe[Int]) - val sink = Sink.fromGraph(FlowGraph.create(Sink(probes(0)), Sink(probes(1)))(List(_, _)) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(Sink(probes(0)), Sink(probes(1)))(List(_, _)) { implicit b ⇒ (s0, s1) ⇒ val bcast = b.add(Broadcast[Int](3)) bcast.out(0).filter(_ == 0) ~> s0.inlet @@ -73,7 +73,7 @@ class SinkSpec extends AkkaSpec { "be composable with importing 3 modules" in { val probes = Array.fill(3)(TestSubscriber.manualProbe[Int]) - val sink = Sink.fromGraph(FlowGraph.create(Sink(probes(0)), Sink(probes(1)), Sink(probes(2)))(List(_, _, _)) { implicit b ⇒ + val sink = Sink.fromGraph(GraphDSL.create(Sink(probes(0)), Sink(probes(1)), Sink(probes(2)))(List(_, _, _)) { implicit b ⇒ (s0, s1, s2) ⇒ val bcast = b.add(Broadcast[Int](3)) bcast.out(0).filter(_ == 0) ~> s0.inlet diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SourceSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SourceSpec.scala index e6a33a87d0..d4bfd64dd4 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SourceSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/SourceSpec.scala @@ -136,9 +136,9 @@ class SourceSpec extends AkkaSpec { val source = Source.subscriber[Int] val out = TestSubscriber.manualProbe[Int] - val s = Source.fromGraph(FlowGraph.create(source, source, source, source, source)(Seq(_, _, _, _, _)) { implicit b ⇒ + val s = Source.fromGraph(GraphDSL.create(source, source, source, source, source)(Seq(_, _, _, _, _)) { implicit b ⇒ (i0, i1, i2, i3, i4) ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val m = b.add(Merge[Int](5)) i0.outlet ~> m.in(0) i1.outlet ~> m.in(1) @@ -212,7 +212,7 @@ class SourceSpec extends AkkaSpec { "Repeat Source" must { "repeat as long as it takes" in { - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val result = Await.result(Source.repeat(42).grouped(10000).runWith(Sink.head), 1.second) result.size should ===(10000) result.toSet should ===(Set(42)) diff --git a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/TickSourceSpec.scala b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/TickSourceSpec.scala index b93de9771d..be6329fd12 100644 --- a/akka-stream-tests/src/test/scala/akka/stream/scaladsl/TickSourceSpec.scala +++ b/akka-stream-tests/src/test/scala/akka/stream/scaladsl/TickSourceSpec.scala @@ -67,8 +67,8 @@ class TickSourceSpec extends AkkaSpec { "be usable with zip for a simple form of rate limiting" in { val c = TestSubscriber.manualProbe[Int]() - RunnableGraph.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val zip = b.add(Zip[Int, String]()) Source(1 to 100) ~> zip.in0 Source.tick(1.second, 1.second, "tick") ~> zip.in1 diff --git a/akka-stream/src/main/boilerplate/akka/stream/javadsl/GraphCreate.scala.template b/akka-stream/src/main/boilerplate/akka/stream/javadsl/GraphCreate.scala.template index edfb89ee35..d123124b70 100644 --- a/akka-stream/src/main/boilerplate/akka/stream/javadsl/GraphCreate.scala.template +++ b/akka-stream/src/main/boilerplate/akka/stream/javadsl/GraphCreate.scala.template @@ -9,34 +9,34 @@ import akka.japi.function private[stream] abstract class GraphCreate { /** - * Creates a new [[Graph]] of the given [[Shape]] by passing a [[FlowGraph.Builder]] to the given create function. + * Creates a new [[Graph]] of the given [[Shape]] by passing a [[GraphDSL.Builder]] to the given create function. */ - def create[S <: Shape](block: function.Function[FlowGraph.Builder[Unit], S]): Graph[S, Unit] = - scaladsl.FlowGraph.create() { b ⇒ block.apply(b.asJava) } + def create[S <: Shape](block: function.Function[GraphDSL.Builder[Unit], S]): Graph[S, Unit] = + scaladsl.GraphDSL.create() { b ⇒ block.apply(b.asJava) } /** * Creates a new [[Graph]] by importing the given graph `g1` and its [[Shape]] - * along with the [[FlowGraph.Builder]] to the given create function. + * along with the [[GraphDSL.Builder]] to the given create function. */ def create[S1 <: Shape, S <: Shape, M](g1: Graph[S1, M], - block: function.Function2[FlowGraph.Builder[M], S1, S]): Graph[S, M] = - scaladsl.FlowGraph.create(g1) { b ⇒ s => block.apply(b.asJava, s) } + block: function.Function2[GraphDSL.Builder[M], S1, S]): Graph[S, M] = + scaladsl.GraphDSL.create(g1) { b ⇒ s => block.apply(b.asJava, s) } /** * Creates a new [[Graph]] by importing the given graphs and passing their [[Shape]]s - * along with the [[FlowGraph.Builder]] to the given create function. + * along with the [[GraphDSL.Builder]] to the given create function. */ def create[S1 <: Shape, S2 <: Shape, S <: Shape, M1, M2, M](g1: Graph[S1, M1], g2: Graph[S2, M2], combineMat: function.Function2[M1, M2, M], - block: function.Function3[FlowGraph.Builder[M], S1, S2, S]): Graph[S, M] = - scaladsl.FlowGraph.create(g1, g2)(combineMat.apply) { b => (s1, s2) => block.apply(b.asJava, s1, s2) } + block: function.Function3[GraphDSL.Builder[M], S1, S2, S]): Graph[S, M] = + scaladsl.GraphDSL.create(g1, g2)(combineMat.apply) { b => (s1, s2) => block.apply(b.asJava, s1, s2) } [3..21#/** * Creates a new [[Graph]] by importing the given graphs and passing their [[Shape]]s - * along with the [[FlowGraph.Builder]] to the given create function. + * along with the [[GraphDSL.Builder]] to the given create function. */ def create1[[#S1 <: Shape#], S <: Shape, [#M1#], M]([#g1: Graph[S1, M1]#], combineMat: function.Function1[[#M1#], M], - block: function.Function2[FlowGraph.Builder[M], [#S1#], S]): Graph[S, M] = - scaladsl.FlowGraph.create([#g1#])(combineMat.apply) { b => ([#s1#]) => block.apply(b.asJava, [#s1#]) }# + block: function.Function2[GraphDSL.Builder[M], [#S1#], S]): Graph[S, M] = + scaladsl.GraphDSL.create([#g1#])(combineMat.apply) { b => ([#s1#]) => block.apply(b.asJava, [#s1#]) }# ] } diff --git a/akka-stream/src/main/boilerplate/akka/stream/scaladsl/GraphApply.scala.template b/akka-stream/src/main/boilerplate/akka/stream/scaladsl/GraphApply.scala.template index a2c2e48ec2..721ba2a11d 100644 --- a/akka-stream/src/main/boilerplate/akka/stream/scaladsl/GraphApply.scala.template +++ b/akka-stream/src/main/boilerplate/akka/stream/scaladsl/GraphApply.scala.template @@ -9,10 +9,10 @@ import akka.stream.{ Graph, Attributes, Shape } trait GraphApply { /** - * Creates a new [[Graph]] by passing a [[FlowGraph.Builder]] to the given create function. + * Creates a new [[Graph]] by passing a [[GraphDSL.Builder]] to the given create function. */ - def create[S <: Shape]()(buildBlock: FlowGraph.Builder[Unit] ⇒ S): Graph[S, Unit] = { - val builder = new FlowGraph.Builder + def create[S <: Shape]()(buildBlock: GraphDSL.Builder[Unit] ⇒ S): Graph[S, Unit] = { + val builder = new GraphDSL.Builder val s = buildBlock(builder) val mod = builder.module.nest().replaceShape(s) @@ -21,10 +21,10 @@ trait GraphApply { /** * Creates a new [[Graph]] by importing the given graph `g1` and passing its [[Shape]] - * along with the [[FlowGraph.Builder]] to the given create function. + * along with the [[GraphDSL.Builder]] to the given create function. */ - def create[S <: Shape, Mat](g1: Graph[Shape, Mat])(buildBlock: FlowGraph.Builder[Mat] ⇒ (g1.Shape) ⇒ S): Graph[S, Mat] = { - val builder = new FlowGraph.Builder + def create[S <: Shape, Mat](g1: Graph[Shape, Mat])(buildBlock: GraphDSL.Builder[Mat] ⇒ (g1.Shape) ⇒ S): Graph[S, Mat] = { + val builder = new GraphDSL.Builder val s1 = builder.add(g1) val s = buildBlock(builder)(s1) val mod = builder.module.nest().replaceShape(s) @@ -37,10 +37,10 @@ trait GraphApply { /** * Creates a new [[Graph]] by importing the given graphs and passing their [[Shape]]s - * along with the [[FlowGraph.Builder]] to the given create function. + * along with the [[GraphDSL.Builder]] to the given create function. */ - def create[S <: Shape, Mat, [#M1#]]([#g1: Graph[Shape, M1]#])(combineMat: ([#M1#]) ⇒ Mat)(buildBlock: FlowGraph.Builder[Mat] ⇒ ([#g1.Shape#]) ⇒ S): Graph[S, Mat] = { - val builder = new FlowGraph.Builder + def create[S <: Shape, Mat, [#M1#]]([#g1: Graph[Shape, M1]#])(combineMat: ([#M1#]) ⇒ Mat)(buildBlock: GraphDSL.Builder[Mat] ⇒ ([#g1.Shape#]) ⇒ S): Graph[S, Mat] = { + val builder = new GraphDSL.Builder val curried = combineMat.curried val s##1 = builder.add(g##1, (m##1: M##1) ⇒ curried(m##1)) [2..#val s1 = builder.add(g1, (f: M1 ⇒ Any, m1: M1) ⇒ f(m1))# diff --git a/akka-stream/src/main/scala/akka/stream/Attributes.scala b/akka-stream/src/main/scala/akka/stream/Attributes.scala index a6815c12db..b3b3809b68 100644 --- a/akka-stream/src/main/scala/akka/stream/Attributes.scala +++ b/akka-stream/src/main/scala/akka/stream/Attributes.scala @@ -10,7 +10,7 @@ import akka.japi.function /** * Holds attributes which can be used to alter [[akka.stream.scaladsl.Flow]] / [[akka.stream.javadsl.Flow]] - * or [[akka.stream.scaladsl.FlowGraph]] / [[akka.stream.javadsl.FlowGraph]] materialization. + * or [[akka.stream.scaladsl.GraphDSL]] / [[akka.stream.javadsl.GraphDSL]] materialization. * * Note that more attributes for the [[ActorMaterializer]] are defined in [[ActorAttributes]]. */ diff --git a/akka-stream/src/main/scala/akka/stream/io/SslTls.scala b/akka-stream/src/main/scala/akka/stream/io/SslTls.scala index 1330060860..8433417969 100644 --- a/akka-stream/src/main/scala/akka/stream/io/SslTls.scala +++ b/akka-stream/src/main/scala/akka/stream/io/SslTls.scala @@ -152,7 +152,7 @@ object SslTls { */ object SslTlsPlacebo { val forScala: scaladsl.BidiFlow[SslTlsOutbound, ByteString, ByteString, SessionBytes, Unit] = - scaladsl.BidiFlow.fromGraph(scaladsl.FlowGraph.create() { implicit b ⇒ + scaladsl.BidiFlow.fromGraph(scaladsl.GraphDSL.create() { implicit b ⇒ // this constructs a session for (invalid) protocol SSL_NULL_WITH_NULL_NULL val session = SSLContext.getDefault.createSSLEngine.getSession val top = b.add(scaladsl.Flow[SslTlsOutbound].collect { case SendBytes(bytes) ⇒ bytes }) diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala index 61b8824e3f..5cf58dcb1c 100644 --- a/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala @@ -964,9 +964,9 @@ final class Flow[-In, +Out, +Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends */ def zipMat[T, M, M2](that: Graph[SourceShape[T], M], matF: function.Function2[Mat, M, M2]): javadsl.Flow[In, Out @uncheckedVariance Pair T, M2] = - this.viaMat(Flow.fromGraph(FlowGraph.create(that, - new function.Function2[FlowGraph.Builder[M], SourceShape[T], FlowShape[Out, Out @ uncheckedVariance Pair T]] { - def apply(b: FlowGraph.Builder[M], s: SourceShape[T]): FlowShape[Out, Out @uncheckedVariance Pair T] = { + this.viaMat(Flow.fromGraph(GraphDSL.create(that, + new function.Function2[GraphDSL.Builder[M], SourceShape[T], FlowShape[Out, Out @ uncheckedVariance Pair T]] { + def apply(b: GraphDSL.Builder[M], s: SourceShape[T]): FlowShape[Out, Out @uncheckedVariance Pair T] = { val zip: FanInShape2[Out, T, Out Pair T] = b.add(Zip.create[Out, T]) b.from(s).toInlet(zip.in1) FlowShape(zip.in0, zip.out) diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Graph.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Graph.scala index 844505ca92..f676ff255e 100644 --- a/akka-stream/src/main/scala/akka/stream/javadsl/Graph.scala +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Graph.scala @@ -270,18 +270,18 @@ object Concat { // flow graph // -object FlowGraph extends GraphCreate { +object GraphDSL extends GraphCreate { /** - * Start building a [[FlowGraph]]. + * Start building a [[GraphDSL]]. * * The [[Builder]] is mutable and not thread-safe, - * thus you should construct your Graph and then share the constructed immutable [[FlowGraph]]. + * thus you should construct your Graph and then share the constructed immutable [[GraphDSL]]. */ - def builder[M](): Builder[M] = new Builder()(new scaladsl.FlowGraph.Builder[M]) + def builder[M](): Builder[M] = new Builder()(new scaladsl.GraphDSL.Builder[M]) - final class Builder[+Mat]()(private implicit val delegate: scaladsl.FlowGraph.Builder[Mat]) { self ⇒ - import akka.stream.scaladsl.FlowGraph.Implicits._ + final class Builder[+Mat]()(private implicit val delegate: scaladsl.GraphDSL.Builder[Mat]) { self ⇒ + import akka.stream.scaladsl.GraphDSL.Implicits._ /** * Import a graph into this module, performing a deep copy, discarding its diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/BidiFlow.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/BidiFlow.scala index 4071c8646c..5e17d0c2af 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/BidiFlow.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/BidiFlow.scala @@ -116,7 +116,7 @@ final class BidiFlow[-I1, +O1, -I2, +O2, +Mat](private[stream] override val modu * Turn this BidiFlow around by 180 degrees, logically flipping it upside down in a protocol stack. */ def reversed: BidiFlow[I2, O2, I1, O1, Mat] = { - BidiFlow.fromGraph(FlowGraph.create(this) { implicit b ⇒ + BidiFlow.fromGraph(GraphDSL.create(this) { implicit b ⇒ reversed ⇒ BidiShape(reversed.in2, reversed.out2, reversed.in1, reversed.out1) }) @@ -169,7 +169,7 @@ object BidiFlow { def fromFlowsMat[I1, O1, I2, O2, M1, M2, M]( flow1: Graph[FlowShape[I1, O1], M1], flow2: Graph[FlowShape[I2, O2], M2])(combine: (M1, M2) ⇒ M): BidiFlow[I1, O1, I2, O2, M] = - fromGraph(FlowGraph.create(flow1, flow2)(combine) { + fromGraph(GraphDSL.create(flow1, flow2)(combine) { implicit b ⇒ (f1, f2) ⇒ BidiShape(f1.inlet, f1.outlet, f2.inlet, f2.outlet) }) diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala index 1786adb536..7f06d909d5 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala @@ -285,7 +285,7 @@ object Flow { * Helper to create `Flow` from a `Sink`and a `Source`. */ def fromSinkAndSourceMat[I, O, M1, M2, M](sink: Graph[SinkShape[I], M1], source: Graph[SourceShape[O], M2])(f: (M1, M2) ⇒ M): Flow[I, O, M] = - fromGraph(FlowGraph.create(sink, source)(f) { implicit b ⇒ (in, out) ⇒ FlowShape(in.inlet, out.outlet) }) + fromGraph(GraphDSL.create(sink, source)(f) { implicit b ⇒ (in, out) ⇒ FlowShape(in.inlet, out.outlet) }) } object RunnableGraph { @@ -1192,9 +1192,9 @@ trait FlowOps[+Out, +Mat] { * @see [[#zip]]. */ def zipMat[U, Mat2, Mat3](that: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) ⇒ Mat3): Repr[(Out, U), Mat3] = - this.viaMat(FlowGraph.create(that) { implicit b ⇒ + this.viaMat(GraphDSL.create(that) { implicit b ⇒ r ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val zip = b.add(Zip[Out, U]()) r ~> zip.in1 FlowShape(zip.in0, zip.out) @@ -1222,9 +1222,9 @@ trait FlowOps[+Out, +Mat] { * @see [[#zipWith]]. */ def zipWithMat[Out2, Out3, Mat2, Mat3](that: Graph[SourceShape[Out2], Mat2])(combine: (Out, Out2) ⇒ Out3)(matF: (Mat, Mat2) ⇒ Mat3): Repr[Out3, Mat3] = - this.viaMat(FlowGraph.create(that) { implicit b ⇒ + this.viaMat(GraphDSL.create(that) { implicit b ⇒ r ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val zip = b.add(ZipWith[Out, Out2, Out3](combine)) r ~> zip.in1 FlowShape(zip.in0, zip.out) @@ -1252,9 +1252,9 @@ trait FlowOps[+Out, +Mat] { * @see [[#merge]]. */ def mergeMat[U >: Out, Mat2, Mat3](that: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) ⇒ Mat3): Repr[U, Mat3] = - this.viaMat(FlowGraph.create(that) { implicit b ⇒ + this.viaMat(GraphDSL.create(that) { implicit b ⇒ r ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val merge = b.add(Merge[U](2)) r ~> merge.in(1) FlowShape(merge.in(0), merge.out) @@ -1294,9 +1294,9 @@ trait FlowOps[+Out, +Mat] { * @see [[#concat]]. */ def concatMat[U >: Out, Mat2, Mat3](that: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) ⇒ Mat3): Repr[U, Mat3] = - this.viaMat(FlowGraph.create(that) { implicit b ⇒ + this.viaMat(GraphDSL.create(that) { implicit b ⇒ r ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val merge = b.add(Concat[U]()) r ~> merge.in(1) FlowShape(merge.in(0), merge.out) @@ -1332,9 +1332,9 @@ trait FlowOps[+Out, +Mat] { * @see [[#alsoTo]] */ def alsoToMat[Mat2, Mat3](that: Graph[SinkShape[Out], Mat2])(matF: (Mat, Mat2) ⇒ Mat3): Repr[Out, Mat3] = - this.viaMat(FlowGraph.create(that) { implicit b ⇒ + this.viaMat(GraphDSL.create(that) { implicit b ⇒ r ⇒ - import FlowGraph.Implicits._ + import GraphDSL.Implicits._ val bcast = b.add(Broadcast[Out](2)) bcast.out(1) ~> r FlowShape(bcast.in, bcast.out(0)) diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala index 71a46d4893..e745392964 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala @@ -555,7 +555,7 @@ class Concat[T](inputCount: Int) extends GraphStage[UniformFanInShape[T, T]] { } } -object FlowGraph extends GraphApply { +object GraphDSL extends GraphApply { class Builder[+M] private[stream] () { private var moduleInProgress: Module = EmptyModule @@ -563,7 +563,7 @@ object FlowGraph extends GraphApply { /** * INTERNAL API */ - private[FlowGraph] def addEdge[T, U >: T](from: Outlet[T], to: Inlet[U]): Unit = + private[GraphDSL] def addEdge[T, U >: T](from: Outlet[T], to: Inlet[U]): Unit = moduleInProgress = moduleInProgress.wire(from, to) /** @@ -634,7 +634,7 @@ object FlowGraph extends GraphApply { private[stream] def module: Module = moduleInProgress /** Converts this Scala DSL element to it's Java DSL counterpart. */ - def asJava: javadsl.FlowGraph.Builder[M] = new javadsl.FlowGraph.Builder()(this) + def asJava: javadsl.GraphDSL.Builder[M] = new javadsl.GraphDSL.Builder()(this) } object Implicits { diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala index 86d2f00669..799db83ecc 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala @@ -154,8 +154,8 @@ object Sink { */ def combine[T, U](first: Sink[U, _], second: Sink[U, _], rest: Sink[U, _]*)(strategy: Int ⇒ Graph[UniformFanOutShape[T, U], Unit]): Sink[T, Unit] = - Sink.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + Sink.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val d = b.add(strategy(rest.size + 2)) d.out(0) ~> first d.out(1) ~> second diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala index 046390be76..22f6fc068d 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala @@ -119,8 +119,8 @@ final class Source[+Out, +Mat](private[stream] override val module: Module) * Combines several sources with fun-in strategy like `Merge` or `Concat` and returns `Source`. */ def combine[T, U](first: Source[T, _], second: Source[T, _], rest: Source[T, _]*)(strategy: Int ⇒ Graph[UniformFanInShape[T, U], Unit]): Source[U, Unit] = - Source.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + Source.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val c = b.add(strategy(rest.size + 2)) first ~> c.in(0) second ~> c.in(1) @@ -330,8 +330,8 @@ object Source { * Combines several sources with fun-in strategy like `Merge` or `Concat` and returns `Source`. */ def combine[T, U](first: Source[T, _], second: Source[T, _], rest: Source[T, _]*)(strategy: Int ⇒ Graph[UniformFanInShape[T, U], Unit]): Source[U, Unit] = - Source.fromGraph(FlowGraph.create() { implicit b ⇒ - import FlowGraph.Implicits._ + Source.fromGraph(GraphDSL.create() { implicit b ⇒ + import GraphDSL.Implicits._ val c = b.add(strategy(rest.size + 2)) first ~> c.in(0) second ~> c.in(1) diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/package.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/package.scala index 4ddad29402..f76ea0b218 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/package.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/package.scala @@ -26,7 +26,7 @@ package akka.stream * * You can create your `Source`, `Flow` and `Sink` in any order and then wire them together before * they are materialized by connecting them using [[Flow#via]] and [[Flow#to]], or connecting them into a - * [[FlowGraph]] with fan-in and fan-out elements. + * [[GraphDSL]] with fan-in and fan-out elements. * * See Reactive Streams for * details on [[org.reactivestreams.Publisher]] and [[org.reactivestreams.Subscriber]].