Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Created January 14, 2016 07:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pjazdzewski1990/b5064a920bba6bd7bbda to your computer and use it in GitHub Desktop.
import akka.pattern.ask
import akka.pattern.pipe
//case 1:
class ServiceActor extends Actor {
//...
def receive = Receive {
case DoSomeVeryComplexCalculationsRequest(taskDef) =>
(specialAgent ? DoTheMath(taskDef)).mapTo[Option[User]] pipeTo sender
}
//...
def specialAgent = context actorOf SpecialAgent.props
}
// case 2:
class HttpRouteHandlerActor(repository: ActorRef) extends Actor {
//...
def receive = {
case GimmeUser(id) =>
(repository ? GetUserFromRepo(id)).mapTo[Option[User]] pipeTo sender
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment