On Fri, Apr 8, 2016 at 1:06 PM, Chris Baxter <cbax...@gmail.com> wrote:

> 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)
>

This does not return the entire body as a ByteString.


> 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.
>
My question is: why do you need to eagerly read everything into memory to
"do something with the repsonse body"?


>
>
> --
> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,
√

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to