среда, 19 октября 2016 г., 15:47:31 UTC+3 пользователь √ написал: > > Ok, so a sort of "correlator"-stage? >
Exactly. > Yes, so the BidiFlow you create has shared state tied to the intance, not > the mateiralization. > I think you'll need to create a custom GraphStage with a BidiShape. > Yep, thanks for your help -- I've implement such correlator as GraphStage, looks better now. One minor question (docs aren't clear enough there): is it safe to drop `pull(in)` in `in` `onPush()` handler if such `pull(in)` happen in `out` `onPull()` handler? In documentation for custom stages `in` pulled twice (both in `onPush()` and `onPull()`) and in code it is only pulled once. > > >> >> среда, 19 октября 2016 г., 15:23:04 UTC+3 пользователь √ написал: >> >>> >>> >>> On Wed, Oct 19, 2016 at 2:18 PM, Alexey Shuksto <[email protected]> >>> wrote: >>> >>>> 2 Konrad: Yep, in original question I meant not 'DSL construction time' >>>> but 'execution time' thread-safety. Thanks for clarification. >>>> >>>> 2 Victor: Use case is simple: outgoing flow need to store `Promise` of >>>> future remote response in some shared state which then would be completed >>>> by incoming flow. >>>> >>> >>> So it's a bidirectional buffer of Promises and Futures? >>> >>> >>> >>> >>>> There could be as many promises as there were outgoing messages, but >>>> the order of responses are not guaranteed and there could be additional >>>> messages in incoming flow. >>>> >>>> What do you meant by 'actively prevents multiple materializations'? >>>> >>> >>> What happens when you materialize that bidiflow N times? >>> >>> >>>> >>>> среда, 19 октября 2016 г., 14:29:14 UTC+3 пользователь √ написал: >>>>> >>>>> Hi Alexey, >>>>> >>>>> Not only is it not thread-safe, but it also actively prevents multiple >>>>> materializations. >>>>> >>>>> Perhaps if you state your use-case we can suggest an alternative? >>>>> >>>>> On Wed, Oct 19, 2016 at 1:24 PM, Alexey Shuksto <[email protected]> >>>>> wrote: >>>>> >>>>>> Hello hAkkers, >>>>>> >>>>>> Simple example: >>>>>> val zipper = BidiFlow.fromGraph(GraphDSL.create() { b => >>>>>> var counter = 0 >>>>>> >>>>>> val outbound = b.add(Flow[String].map { str => >>>>>> counter += 1 >>>>>> str -> counter >>>>>> }) >>>>>> val inbound = b.add(Flow[(String, Int)].map { pair => >>>>>> counter -= 1 >>>>>> pair._1 >>>>>> }) >>>>>> >>>>>> BidiShape.fromFlows(outbound, inbound) >>>>>> }) >>>>>> >>>>>> Can I presume that contents of 'build block' is thread-safe or I need >>>>>> to guard `counter` somehow (use `AtomicInt` and such)? >>>>>> >>>>>> Also, do BidiFlow support 'duplex' mode or they process >>>>>> incoming/outgoing messages one at time? >>>>>> >>>>>> -- >>>>>> >>>>>>>>>> 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. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> 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 [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. >>>> >>> >>> >>> >>> -- >>> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> 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 [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.
