среда, 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.
>
On Wed, Oct 19, 2016 at 2:43 PM, Alexey Shuksto wrote:
> 1. Flow itself is a bidi-codec from ByteString to our own Request/Response
> entities. Each Request has Promise[Response] attribute. Shared state is
> more like Map[Request.Id, Promise[Response]] -- because order of
1. Flow itself is a bidi-codec from ByteString to our own Request/Response
entities. Each Request has Promise[Response] attribute. Shared state is
more like Map[Request.Id, Promise[Response]] -- because order of Responses
are not guarantied.
2. It should have state shared only "inside" this
On Wed, Oct 19, 2016 at 2:18 PM, Alexey Shuksto 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
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
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 wrote:
> Hello hAkkers,
>
> Simple example:
> val zipper =
This is not safe, outbound and inbound flows could be executing on
different threads.
It's not a question about the the DSL being safe - that's fine as it's only
constructing stuff,
but the graph you constructed is accessing shared state from (potentially)
different threads - thus it is not safe.
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
})