!str #19732 Concise and consistent way to mark async boundaries
This commit is contained in:
parent
d154fad4e9
commit
4e49d75ad8
25 changed files with 125 additions and 194 deletions
|
|
@ -237,11 +237,8 @@ class FlowDocSpec extends AkkaSpec {
|
|||
|
||||
"defining asynchronous boundaries" in {
|
||||
//#flow-async
|
||||
import akka.stream.Attributes.asyncBoundary
|
||||
|
||||
Source(List(1, 2, 3))
|
||||
.map(_ + 1)
|
||||
.withAttributes(asyncBoundary)
|
||||
.map(_ + 1).async
|
||||
.map(_ * 2)
|
||||
.to(Sink.ignore)
|
||||
//#flow-async
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ class MigrationsScala extends AkkaSpec {
|
|||
})
|
||||
})
|
||||
//#expand-state
|
||||
|
||||
//#async
|
||||
val flow = Flow[Int].map(_ + 1)
|
||||
Source(1 to 10).via(flow.async)
|
||||
//#async
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,21 @@ Which is the same as using ``conflateWithSeed`` with an identity function
|
|||
|
||||
Flow[Int].conflateWithSeed(identity)(_ + _) // Add numbers while downstream is not ready
|
||||
|
||||
|
||||
``viaAsync`` and ``viaAsyncMat`` has been replaced with ``async``
|
||||
-----------------------------------------------------------------
|
||||
``async`` is available from ``Sink``, ``Source``, ``Flow`` and the sub flows. It provides a shortcut for
|
||||
setting the attribute ``Attributes.asyncBoundary`` on a flow. The existing methods ``Flow.viaAsync`` and
|
||||
``Flow.viaAsyncMat`` has been removed to make marking out asynchronous boundaries more consistent::
|
||||
|
||||
// This no longer works
|
||||
source.viaAsync(flow)
|
||||
|
||||
In Akka 2.4.x this will instead look lile this:
|
||||
|
||||
.. includecode:: ../code/docs/stream/MigrationsScala.scala#async
|
||||
|
||||
|
||||
Changes in Akka HTTP
|
||||
====================
|
||||
|
||||
|
|
|
|||
|
|
@ -245,8 +245,9 @@ The first point can be countered by pre-fusing and then reusing a stream bluepri
|
|||
.. includecode:: ../code/docs/stream/FlowDocSpec.scala#explicit-fusing
|
||||
|
||||
In order to balance the effects of the second and third bullet points you will have to insert asynchronous
|
||||
boundaries manually into your flows and graphs by way of adding ``Attributes.asyncBoundary`` to pieces that
|
||||
shall communicate with the rest of the graph in an asynchronous fashion.
|
||||
boundaries manually into your flows and graphs by way of adding ``Attributes.asyncBoundary`` using the method
|
||||
``async`` on ``Source``, ``Sink`` and ``Flow`` to pieces that shall communicate with the rest of the graph in an
|
||||
asynchronous fashion.
|
||||
|
||||
.. includecode:: ../code/docs/stream/FlowDocSpec.scala#flow-async
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue