Howdy, all! I originally talked up the Requester pattern a year or two ago, when I had just started playing with it seriously. It's now matured quite a bit and become rather more complete, and is being used heavily in production for Querki. And since I've gotten used to releasing open-source libraries for Scala.js, I figure it's time to make Requester more generally available.
Full details can be found here on GitHub <https://github.com/jducoeur/Requester>, but to give you a sense of what this library is, I'll quote from the introduction to the documentation there: ============================= One of the most useful, and most fraught, functions in Akka is ask. On the one hand, it is invaluable for writing clear, understandable code -- after all, the pattern of "Send this message, and then do that with the result" makes loads of sense, and it's usually easy to see what the code is trying to do. On the other hand, ask is something of a landmine in practice, because it violates the most important invariant of Actors: there should never be code lexically inside of the Actor that doesn't run within the Actor's receive loop. ask returns a Future, and that Future will be run out-of-band, at some random time in the future. It can happen in parallel with running receive code, or not. There is lots of danger there, and it is easy to cause erratic, hard-to-reproduce bugs. (Not to mention the fact that sender probably won't be set to the value you expect during the response handler. One of the easiest Akka traps to fall into is using sender during a Future, which almost never works.) This library introduces request, which you can think of as the better-behaved big brother of ask. The look and feel is similar, but there is one crucial difference: the response handler from request is *not* Future, and it runs inside the normal receive loop. Also, unlike ask, request preserves the value of sender. The result is that you can safely write straightforward, intuitive, composable code for complex multi-Actor operations, like this: case GetSpacesStatus(requester) => { for { ActiveThings(nConvs) <- conversations.request(GetActiveThings) ActiveSessions(nSessions) <- sessions.request(GetActiveSessions) } sender ! SpaceStatus(spaceId, state.displayName, nConvs, nSessions) } and have it work just as you expect. ============================== Obviously, this is less important to newfangled code that is entirely hooked together with akka-streams, but I suspect I'm not the only person still using Plain Old Akka heavily. So -- have fun, and tell me what you think. Bug reports and pull requests welcomed: while this is working well for me, I'm sure folks will come up with enhancements they'd like to add... -- >>>>>>>>>> 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.
