ask-style syntax for ordinary requests.
ask-style syntax for ordinary requests.
This *intentionally* conflicts with akka.pattern.ask, on the grounds that if you're in an askable situation, it is generally a bug to be using raw asks. So if you wind up with ambiguity, that's a warning sign.
(I might be willing to break this out, to make it possible to work around it, but somebody's going to have to convince me it's a good idea to do so. If you really want to use ask, then spell it out explicitly.)
The basic, simple version of request() -- sends a message, process the response.
The basic, simple version of request() -- sends a message, process the response.
You can think of request as a better-behaved version of ask. Where ask sends a message to the target actor, and gives you a Future that will execute when the response is received, request does the same thing but will process the resulting RequestM in the Actor's receive loop. While this doesn't save you from every possible problem, it makes it much easier to write clear and complex operations, involving coordinating several different Actors, without violating the central invariants of the Actor model.
The current sender will be preserved and will be active during the processing of the results, so you can use it as normal.
This version of the call does not impose any expectations on the results. You can use a destructuring case class in a for comprehension if you want just a single return type, or you can map the RequestM to a PartialFunction in order to handle several possible returns.
The message to send to the target actor.
The number of times to retry this request, if it times out.
A more strongly-typed version of request().
A more strongly-typed version of request().
This works pretty much exactly like request, but expects that the response will be of type T. It will throw a ClassCastException if anything else is received. Otherwise, it is identical to request().
Hook to add the request() methods to a third-party Actor.