Hi Simon,

you could also try to split up the asynchronous computation and the actual 
filtering like this:

def filterFunc(e: E): Future[Result]

xyz.mapAsync(n)(e => filterFunc(e).map(res => e -> res))

And then implement the `statefulFilterGraphStage` with whatever stateful 
logic you need. The advantage would be that you don't need to manage 
asynchronous future completion in the single stage.

Would that work?


On Friday, September 16, 2016 at 9:52:20 AM UTC+2, Simon Lam wrote:
> Hello!
> I would like to build a custom GraphStage that essentially filters out 
> elements based on a comparison made against the result of a Future and 
> would like to retain this value for future elements.  Additionally, I would 
> also like to preserve the order in which elements pass through filter.  My 
> current implementation uses mapAsync with parallelism factor set to 1 and 
> an actor that executes the future and maintains state.  It pipes results 
> back to self for processing and then sends it back to the temp sender 
> created in the mapAsync call.  Is this approach appropriate?
> Would you be able to provide any high level guidance on how to accomplish 
> this in a custom GraphStage?  I think I grasp how AsyncCallbacks work but 
> am not 100% sure about how to guarantee order.  If I execute separate 
> Futures for each upstream push, there is the chance they may finish out of 
> order? 
> Any advice is greatly appreciated - thank you in advance!


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