Hi John,

On Tue, Jan 12, 2016 at 6:12 PM, <[email protected]> wrote:

> Isn't the following case typical for dealing with Http().superPool(...) flows?
> The superPool flow lets me nicely attach context to the HttResponse.
>
> Now I do not want to materialize the  getDataBytes Source right away but pass 
> it to flatMapConcat.
> Like in the following pseudo java code:
>
> 1) Flow<Pair<HttpRequest, Object>, Pair<Try<HttpResponse>, Object>, 
> BoxedUnit> flow = httpClient.<Object>request();
> 2) Flow<Object, ByteString, BoxedUnit> byteStringFlow = 
> responseFlow.flatMapConcat(pair -> {
> 3)   // How to also pass pair.second() back?
> 4)   return pair.first().get().entity().getDataBytes();
> 5) });
>
> Ok, so if I understood correctly, you want to attach the context to the
concatenated response bytes. One thing you can do is to end up with instead
of a stream of ByteStrings to have a stream of (ByteString, Context):

return pair.first().get().entity().getDataBytes().map(bytes ->
Pair.of(bytes, pair.second()))

Alternative is to have a stream of domain objects extending the same
interface:
 - Separator(Context ctx)
 - Data(ByteString payload)

then your code will be

return Source.single(new
Separator(pair.second())).concat(pair.first().get().entity().getDataBytes().map(bytes
-> new Data(bytes)))

-Endre

>
>
> In the above code I would like to also pass the context in pair.second() 
> downstream. I guess this is not possible with the simple flows api?
> Does akka streams support a getDataBytes() with context flow?
>
>
> --
> >>>>>>>>>> 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.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

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

Reply via email to