From the scaladoc for trait Flow[-In, +Out] (package akka.stream.scaladsl):
A
Flowis a set of stream processing steps that has one open input and one open output.
Therefore, Flow[HttpRequest, HttpResponse] is a set of stream processing steps that has one open HttpRequest input and one open HttpResponse output.
It appears that inputs are called Sources and outputs are Sinks. Connecting a Source to a Sink creates a flow graph.
That's pretty much the good ol' Spray.
There’s the companion object Flow
trait ActorPublisher[T] extends Actortrait ActorSubscriber extends Actor
What does Props(new ManualSubscriber(probe)).withDispatcher("akka.test.stream-dispatcher”) do?
From the scaladoc:
Extend/mixin this trait in your akka.actor.Actor to make it a stream subscriber with full control of stream back pressure.
Questions:
- What's a stream subscriber?
- What's a stream backpressure?
- How is the full control handled?
- From the scaladoc: the RequestStrategy to control stream back pressure.
Reading the scaladoc further...
Attach the actor as a org.reactivestreams.Subscriber to the stream
Questions:
- What's it to be a
org.reactivestreams.Subscriber?
FIXME Where is the type used in Akka?
object Route seems to contain "the glue" between flows and the good ol' Spray.
type Route = RequestContext ⇒ Future[RouteResult]
def handlerFlow(route: Route)(implicit setup: RoutingSetup): Flow[HttpRequest, HttpResponse]
The term Flow[HttpRequest] is quite heavily used in akka.http.Http.ServerBinding.
Note the type of route - it's Flow[HttpRequest, HttpResponse] (!)
import akka.http.Http
val binding = Http().bind(interface, port)
import system.dispatcher
implicit val mat = FlowMaterializer()
val route: Flow[HttpRequest, HttpResponse] =
get {
path("hello") {
complete("Hello back!")
}
}
binding startHandlingWith route