> On 08 Sep 2015, at 15:46, Richard Rodseth <[email protected]> wrote: > > The original inspiration was the Net-a-Porter article and template > https://github.com/NET-A-PORTER/spray-actor-per-request#master > <https://github.com/NET-A-PORTER/spray-actor-per-request#master> > http://techblog.net-a-porter.com/2013/12/ask-tell-and-per-request-actors/ > <http://techblog.net-a-porter.com/2013/12/ask-tell-and-per-request-actors/> > > At the time we had a lot of timeout issues. Perhaps these were mostly > backpressure-related and we could have used ask at the "edge" of the app.
Yeah, in my small world the route talks to one or more high level service actors via ask and there’s no need to chain asks which of course is a PITA. You can get the idea here: https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/HttpService.scala#L72 <https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/HttpService.scala#L72> Cheers Heiko > The Net-a-Porter approach seems to have worked well for us, and I'm pretty > sure Typesafe folk endorsed the approach here on the list. Certainly chaining > asks seems like something that would be problematic as described in the > article. The template does include a generic trait, and it's easy to create a > "target" of the per-request parent, and create children within that target. > > Perhaps the not-yet-there migration from Spray docs will address best > practices for bridging HTTP with the rest of the app. > > On Mon, Sep 7, 2015 at 10:57 PM, Heiko Seeberger <[email protected] > <mailto:[email protected]>> wrote: >> On 08 Sep 2015, at 07:39, Richard Rodseth <[email protected] >> <mailto:[email protected]>> wrote: >> >> Thanks for the link to that sample. >> The other problem in doing per-request actors without ask pattern, as in the >> net-a-porter sample seems to be that Routes are no longer defined as >> RequestContext => Unit. Any thoughts on that? Are we now required to use >> Futures (or Flows?) to bridge routing with actors? > > Why would you want to use per-request actors at all? As Akka HTTP by default > has an idle-timeout for connections, you should impose a timeout on your > per-request actor anyway. Which you always should do for one-off actors to > avoid memory leaks. That’s exactly what the ask-pattern gives you: one-off > actors with a timeout. > > Cheers > Heiko > >> >> >> On Mon, Sep 7, 2015 at 10:18 PM, Heiko Seeberger <[email protected] >> <mailto:[email protected]>> wrote: >>> On 07 Sep 2015, at 19:32, Richard Rodseth <[email protected] >>> <mailto:[email protected]>> wrote: >>> >>> Maybe just move the bind call into my routing actor, in response to some >>> sort of Start message ? >> >> Yep. >> >> Here’s a similar example: >> https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/HttpService.scala#L133 >> >> <https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/HttpService.scala#L133> >> >> Pay attention to not use any actor state/internals in the route, i.e. define >> the route in the companion object. >> >> Cheers >> Heiko >> >> >>> >>> On Mon, Sep 7, 2015 at 8:38 AM, Richard Rodseth <[email protected] >>> <mailto:[email protected]>> wrote: >>> I'm trying Akka Http for the first time, coming from Spray. In Spray I have >>> a routing actor which extends HttpService and is passed to HttpBind as >>> shown below. This way routes can create per-request actors as a child of >>> the routing actor. >>> What would be the equivalent in Akka Http? >>> >>> I'm not so worried about the bind responder stuff right now, but here's >>> what my Spray initialization looks like: >>> >>> class BindResponder(service: ActorRef, system:ActorSystem) extends Actor >>> with ActorLogging { >>> def receive = { >>> case b @ Http.Bound(connection) => { >>> log.info <http://log.info/>(s"Successfully bound, starting >>> processing $b") >>> ... >>> self ! PoisonPill >>> >>> } >>> case cf @ Http.CommandFailed(command) => { >>> log.error(s"Binding failed, shutting down process $cf") >>> System.exit(0) >>> // TODO In future we might try to shutdown the actor system >>> cleanly, but >>> // that is non-trivial >>> // system.shutdown() >>> } >>> } >>> >>> } >>> >>> val bindResponder = system.actorOf(Props(new BindResponder(serviceActor, >>> system))) >>> >>> IO(Http)(system).tell(Http.Bind(this.routingActor, hostName, port = >>> servicePort),bindResponder) >>> >>> >>> >>> -- >>> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> >>> >>>>>>>>>> Check the FAQ: >>> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> >>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user >>> >>>>>>>>>> <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] >>> <mailto:[email protected]>. >>> To post to this group, send email to [email protected] >>> <mailto:[email protected]>. >>> Visit this group at http://groups.google.com/group/akka-user >>> <http://groups.google.com/group/akka-user>. >>> For more options, visit https://groups.google.com/d/optout >>> <https://groups.google.com/d/optout>. >> >> >> -- >> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> >> >>>>>>>>>> Check the FAQ: >> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> >> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user >> >>>>>>>>>> <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] >> <mailto:[email protected]>. >> To post to this group, send email to [email protected] >> <mailto:[email protected]>. >> Visit this group at http://groups.google.com/group/akka-user >> <http://groups.google.com/group/akka-user>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. >> >> >> -- >> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> >> >>>>>>>>>> Check the FAQ: >> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> >> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user >> >>>>>>>>>> <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] >> <mailto:[email protected]>. >> To post to this group, send email to [email protected] >> <mailto:[email protected]>. >> Visit this group at http://groups.google.com/group/akka-user >> <http://groups.google.com/group/akka-user>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. > > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> > >>>>>>>>>> Check the FAQ: > >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > >>>>>>>>>> <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] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at http://groups.google.com/group/akka-user > <http://groups.google.com/group/akka-user>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> > >>>>>>>>>> Check the FAQ: > >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > >>>>>>>>>> <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] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at http://groups.google.com/group/akka-user > <http://groups.google.com/group/akka-user>. > For more options, visit https://groups.google.com/d/optout > <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.
