To maybe try and formalise this a little bit more, and abstract away from 
WebSockets (that will only muddy the water).

Lets say we have an Actor already that looks like this

sealed trait Incoming
sealed trait Outgoing
class SimpleActor(upstream: ActorRef) extends Actor {
  def receive = {
    case in: Incoming =>
       // work, including some upstream ! outgoing
    case Ack =>
       // ack for the last message upstream
    case other =>
       // work, including some upstream ! outgoing
  }
}

How do I wrap that as a Flow[Incoming, Outgoing, Unit] ?


On Tuesday, 26 May 2015 14:09:45 UTC+1, Sam Halliday wrote:
>
> Re: asyncyMap. I don't think that is going to work, there is no implied 
> single response to each query (which I gather is what you're suggesting)? 
> And I need some way of receiving new messages from upstream.
>
> The existing Actor is both a sink (i.e. it consumes messages from 
> upstream, not necessarily responding to each one) and a source (i.e. it can 
> send an effectively infinite number of messages). It is using backpressure, 
> but only using its own `Ack` message.
>
> For some context, I'm retrofitting some code that is using this WebSockets 
> layer around wandoulabs, e.g. 
> https://github.com/smootoo/simple-spray-websockets/blob/master/src/test/scala/org/suecarter/websocket/WebSocketSpec.scala#L150
>
> But the newly released akka-io layer expects a Flow.
>
> The `Ack` is being received when messages were sent directly to the I/O 
> layer. Presumably, the backpressure is implemented differently now... 
> although I am not sure how yet. That's the second problem once I can 
> actually get everything hooked up.
>
>
> On Tuesday, 26 May 2015 13:57:43 UTC+1, √ wrote:
>>
>> Not knowing what your actor is trying to do, what about Flow.mapAsync + 
>> ask?
>>
>> -- 
>> Cheers,
>> √
>> On 26 May 2015 14:54, "Sam Halliday" <sam.ha...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I need to interface an Actor with an API that requires a Flow.
>>>
>>> The actor can receive a sealed trait family of inputs and will only send 
>>> (a different) sealed family of outputs to upstream, so I suspect that will 
>>> help matters.
>>>
>>> Looking in FlowOps, it looks like I can create a Flow from a partial 
>>> function, but there isn't anything that would just simply take an ActorRef.
>>>
>>> Am I missing something trivial to just upgrade an ActoRef to a Flow? 
>>> (Obviously there is a bunch of extra messages the actor will have to 
>>> handle, such as backpressure messages etc... but assume that's all taken 
>>> care of)
>>>
>>> Best regards,
>>> Sam
>>>
>>> -- 
>>> >>>>>>>>>> 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+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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