Created
June 24, 2013 08:57
-
-
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/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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