Skip to content

Instantly share code, notes, and snippets.

@enijns
Created June 24, 2013 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enijns/5848692 to your computer and use it in GitHub Desktop.
Save enijns/5848692 to your computer and use it in GitHub Desktop.
slightly modified ReplyingActor (inspiration: http://www.warski.org/blog/2013/05/typed-ask-for-akka/)
trait ReplyingActor extends Actor {
final def receive = {
case m: Replyable[_] if receiveReplyable.isDefinedAt(m) => {
try {
sender ! receiveReplyable(m)
} catch {
case e: Exception => sender ! Failure(e)
}
}
case x => receiveOther(x)
}
def receiveReplyable[T]: PartialFunction[Replyable[T], T]
def receiveOther: PartialFunction[Any, Unit]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment