thanks for detailed answer, and yes now I understand it, it just was't 
explained in details in docs and I got impression it should be doable and 
useful :)

On Friday, 18 September 2015 13:07:40 UTC+2, drewhk wrote:
>
> Hi Pawel,
>
> On Fri, Sep 18, 2015 at 12:19 PM, paweł kamiński <[email protected] 
> <javascript:>> wrote:
>
>> exactly, I want to pass my BidiFlow as Flow to some component that knows 
>> how to connect it. so it doesn't really matter if the flow is simple 
>> mapping/codec or some composite structure - which is exactly what you are 
>> describing and I am just passing something more sophisticated.
>>
>> I just cannot find a simple way (apart from my prev comment - where I 
>> simply close BidiFlow from one end and I get a flow as result) to expose 
>> BidiFlow's ends as Flow which would make life more simple.
>>
>
> You cannot do that unfortunately, since Akka needs to enforce that all 
> ports are properly connected. If you would pass it around a BidiFlow as a 
> Flow, then you would be able to materialize it: 
>
>     src.via(bidiFlowAsFlow).runWith(sink)
>
> However, it would not work, since two ports of the BidiFlow would be 
> unconnected. 
>
> You can materialize the BidiFlow with Publishers/Subscribers on all ports 
> though, then re-wrap them in separate Flows. Remember though that in this 
> case those Flows are not reusable.
>
> Example (have not compiled it):
>
>  val publisherSubscriberFlow = Flow.wrap(Sink.publisher, 
> Source.subscriber(Keep.both)
>  val closedBidi = 
> publisherSubscriberFlow.join(bidi).join(publisherSubscriberFlow)
>  val ((topPub, topSub), (bottomPub, bottomSub)) = closedBidi.run()
>
>  val flow1 = Flow.wrap(Sink(topSub), Source(topPub))
>  val flow2 = Flow.wrap(Sink(bottomSub), Source(bottomPub))
>
> Remember though that those flows are no longer reusable since they wrap an 
> already running entity. I personally recommend against this route though, 
> but if there is really no other way, it should work.
>
> -Endre
>  
>
>>
>>
>> On Friday, 18 September 2015 12:09:39 UTC+2, drewhk wrote:
>>>
>>> Hi Pawel,
>>>
>>> The alternative is that it is not the BidiFlow that is provided to the 
>>> part which has the Flow, but the Flow is provided to the part that has the 
>>> BidiFlow. That way the part that has the Flow does not need to know how it 
>>> will be connected in a potentially larger thing.
>>>
>>> -Endre
>>>
>>> On Fri, Sep 18, 2015 at 12:00 PM, paweł kamiński <[email protected]> 
>>> wrote:
>>>
>>>> I guess the answer can be found on the same page I referred.
>>>>
>>>>
>>>>    1. final Flow<Message, Message, BoxedUnit> flow = stack.atop(stack.
>>>>    reversed()).join(pingpong);
>>>>
>>>> I need to close BidiFlow from one end to get Flow of the other end
>>>>
>>>> On Wednesday, 16 September 2015 23:09:46 UTC+2, paweł kamiński wrote:
>>>>>
>>>>> hi,
>>>>>
>>>>> I folowed 
>>>>> http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/java/stream-graphs.html#Bidirectional_Flows
>>>>>  
>>>>> and its section describing BidiFlow but my brain has just fried when I 
>>>>> tried to figure out how to expose left side of such BidiFlow as Flow. 
>>>>>
>>>>> in other words how to hide the fact that we are connecting to BidiFlow.
>>>>>
>>>>> lets stick with example from the page above
>>>>>
>>>>>
>>>>>    1. BidiFlow<Message, ByteString, ByteString, Message, BoxedUnit> 
>>>>>    codecVerbose = BidiFlow.factory().create(b -> {
>>>>>    2. final FlowShape<Message, ByteString> top = b.graph(Flow.<Message
>>>>>    > empty().map(BidiFlowDocTest::toBytes));
>>>>>    3. final FlowShape<ByteString, Message> bottom = b.graph(Flow.<
>>>>>    ByteString> empty().map(BidiFlowDocTest::fromBytes));
>>>>>    4. return new BidiShape<>(top, bottom);
>>>>>    5. });
>>>>>    6. +------+
>>>>>    7. Message ~>| |~> ByteString
>>>>>    8. | bidi |
>>>>>    9. Message <~| |<~ ByteString
>>>>>    10. +------+
>>>>>
>>>>> And I would like to expose to the world a flow like
>>>>>
>>>>>
>>>>>    1. Flow<Message, Message, BoxedUnit> codecVerboseAsFlow = Flow.
>>>>>    factory().create(b -> {
>>>>>    2. b.graph(...);
>>>>>    3. return new Pair<>(??.inlet(), ??.out());
>>>>>    4. });
>>>>>
>>>>> again thanks for help
>>>>>
>>>> -- 
>>>> >>>>>>>>>> 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.
>>>>
>>>
>>> -- 
>> >>>>>>>>>> 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 http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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

Reply via email to