On Mon, Aug 31, 2015 at 12:13 PM, Leon Ma <[email protected]> wrote:

> Hi,
>
> I have below Actor which can return a chunked response:
>
>
> class DemoActor extends Actor {
>
>   override def receive: Receive = {
>     case req: HttpRequest =>
>
>       val source = Source(List(Chunk("Hello"), Chunk("World"), LastChunk))
>       sender() ! HttpResponse(entity =
> HttpEntity.Chunked(ContentTypes.`text/plain`, source))
>
>   }
> }
>
> However, I'd like to drive the source by sending chunks to an actor,
> something like:
>
> class DemoActor extends Actor {
>   implicit val mat = ActorMaterializer()
>
>   override def receive: Receive = {
>     case req: HttpRequest =>
>
>       val source: Source[ChunkStreamPart, ActorRef] = Source.actorRef(10,
> OverflowStrategy.fail)
>
>       sender() ! HttpResponse(entity =
> HttpEntity.Chunked(ContentTypes.`text/plain`, source))
>
>                       val actorRef = "do something to get actorRef"
>
>                       actorRef ! Chunk("Hello")
>                       actorRef ! Chunk("World")
>                       actorRef ! LastChunk()
>
>
>
>   }
> }
>
> Could anyone help me on how to get the actorRef?
>

Good question. That is currently not possible, as far as I know.

A workaround is that you create your own ActorPublisher and send the chunks
via that actor, which then also has to take care of buffering until there
is demand.

Regards,
Patrik


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



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

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