Skip to content

Instantly share code, notes, and snippets.

@rkuhn
Last active December 21, 2015 14:58
Show Gist options
  • Save rkuhn/6322930 to your computer and use it in GitHub Desktop.
Save rkuhn/6322930 to your computer and use it in GitHub Desktop.
package demo
class TopLevel extends Actor {
val db = context.actorOf(Props[Database])
context.watch(db)
val web = context.actorOf(Props[WebServer])
web ! Start(database = db)
override val supervisorStrategy = OneForOneStrategy() {
case _ if sender == db => Stop
case _ if sender == web => Restart
}
def receive = {
case Terminated(`db`) => context stop self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment