Hi Alexey, I don't have any suggestion for a fix, but it does seem like your setup is a bit too entangled. If you take a step back and look at the lifecycle and propagation pattern needed by your solution, is it workable or does it make sense to consider other solutions?
On Mon, Oct 19, 2015 at 7:00 AM, Alexey Romanchuk < [email protected]> wrote: > The problem with this solution is absence of actorRef during upstream > complete. Any ideas how to get it? > > пятница, 16 октября 2015 г., 15:18:51 UTC+6 пользователь Alexey Romanchuk > написал: > >> Finally ended with >> >> ```scala >> val managedMySource = FlowGraph.partial(MySource()) { >> implicit b => source => >> val control = b.add(Flow[Command]]) >> val zip = b.add(Zip[ActorRef, Command]) >> >> b.materializedValue.map(Source.repeat).flatten(FlattenStrategy.concat) ~> >> zip.in0 >> >> control.outlet ~> zip.in1 >> >> zip.out ~> Sink.foreach[(ActorRef, Command)] { >> case (ref, cmd) => ref ! cmd >> } >> >> FlowShape(control.inlet, source.outlet) >> } >> ``` >> >> Any ideas or comments? >> >> >> пятница, 16 октября 2015 г., 11:48:27 UTC+6 пользователь Alexey Romanchuk >> написал: >>> >>> Hey hAkkers! >>> >>> I need your advise in akka streams materialization question. >>> >>> I have custom protocol source `MySource` of type`Source[String, >>> ActorRef]` which accepts messages to control protocol via ActorRef after >>> materialization. Example of message is something like connect to server or >>> change parameters of existing connection and so on. >>> >>> Creation of flow with this API is easy: >>> >>> ``` >>> val actor = MySource().to(Sink.ignore).run >>> actor ! SomeCommand() >>> ``` >>> >>> Next, I have `Source[Command, Unit]` and I want to be able to connect it >>> to `MySource`. So I need to lift `MySource` from source to `Flow`: >>> >>> ``` >>> val source: Source[String, ActorRef] = ??? >>> >>> //some magic with custom stage or partial flow here and >>> val controlledSource: Flow[Command, String, ActorRef] = ??? >>> ``` >>> >>> I tried to do it with partial flow: >>> >>> ``` >>> val flow = FlowGraph.partial() { implicit b => >>> import FlowGraph.Implicits._ >>> val mySource = MySource >>> val commandsInput = Sink.foreach[Command](???) //I need ActorRef >>> here :( >>> FlowShape(b.add(commandsInput).inlet, b.add(mySource).outlet) >>> } >>> ``` >>> >>> but to connect commands with source I need result of materialization. >>> >>> Any ideas how to keep `Source[String, ActorRef]` and have `Flow[Command, >>> String, ActorRef]`? >>> >> -- > >>>>>>>>>> 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 http://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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
