If I want to consume a Http service and then do something with the response
body, there are a couple of ways to go about doing that. The two ones that
I am trying to decide between are:
val f:Future[ByteString] =
Source.single(req).
via(outgoingConn).
flatMapConcat(_.entity.dataBytes).
completionTimeout(timeout).
runWith(Sink.head)
and
val f:Future[ByteString] =
Source.single(req).
via(pool).
mapAsync(1){ resp =>
resp.entity.toStrict(timeout).map(_.data )
}.
completionTimeout(timeout).
runWith(Sink.head)
I'm thinking the first approach is the better one. Up until now, my common
code for making outbound request has been using the second approach. I'm
about to refactor that code into using the first approach as it seems
cleaner and requires less use of Futures. Just wanted to see what the
consensus from the Akka team and others was on this.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.