typesafehub/play2-mini — Issue #4: Add askActor pattern
Author: rkuhn
Created: 2012-02-23 09:17:54+00:00
State: open

Passing on a request to some actors should be sufficiently common to warrant making it nice, e.g.

ActorAction(actorRef, msg, timeout) { reply: String =>
Ok(reply)
}

This should roughly do the following:

Action {
Async {
implicit val t = Timeout(timeout)
(actorRef ? msg).mapTo[String].asPromise.map { reply =>
Ok(reply)
}
}
}

Or it might only do the part inside `Async{}` to allow more flexibility in failure handling.