Ordinary step debugging simply does not work for asynchronous systems as control crosses thread boundaries which the debugger is not aware of.
> I do see how Tweets are parsed from JSON; but then how does the
underlying Akka implementation know the clean Byte boundary to pull data
into?
I don't understand this question. Can you elaborate?
> How would this client typically force
a CLOSE for the socket connection?
> Or, is the assumption that implicit
Actors run as daemons monitoring stream Source input?
I am not sure what do you mean by Actors running as daemons. There are actors yes, they run the stream. And there is a parent actor which is owned by the Materializer. If that actor stops (due to system shutdown or its parent stops) then all the stream code materialized by that materializer also stop. You can also explicitly shutdown a Materializer. KillSwitch is recommended though.
> Does Akka
Http Stream open some kind of Async Http socket connection with push
notifications; and where can I read a clear and reliable explanation of
the essentials for how that works from the NIO layer, through to TCP,
through Reactive Stream, Akka Stream, then Akka Http layers?
I cannot answer this as this seems to be Twitter specific and I don't know the details there. From the code it seems like that it just returns a long HTTP response, i.e. the connection is kept open and new data arrives over time. This is the code that gets the HTTP response body as a stream: response.entity.dataBytes
> Is the
exception handling in this example rigorous; i.e. my Debugger stops
hitting breakpoints, while the process is still running. Where else
needs a Try block?
I am not sure, it is not our code and I am too lazy to review it :)
> Why does the response.status != 200 return a
Future; but the other block of code, not have to create a Future to
return? Certainly streamed data is async; and needs some kind of Future
created -- is this somehow embedded in the Akka Http Stream API?
the request.flatMap { response => } block ensures that you already have the response headers. It is async (flatMap on a Future), and the result of that is two things:
- response metadata/headers available immediately in "response"
- response.entityBytes representing an async stream of potentially arriving body bytes (well, in fact in some cases this might be available already if the request is small enough so that we get the whole thing from TCP in one go)
-Endre