=doc #3531 Recommend orElse’ing super.supervisorStrategy.decider

This commit is contained in:
Patrik Nordwall 2013-08-16 16:47:10 +02:00
parent 822f80bc69
commit 0d859f1424
2 changed files with 23 additions and 0 deletions

View file

@ -63,6 +63,24 @@ object FaultHandlingDocSpec {
}
//#supervisor2
class Supervisor3 extends Actor {
//#default-strategy-fallback
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
import scala.concurrent.duration._
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
case _: ArithmeticException Resume
case t
super.supervisorStrategy.decider.applyOrElse(t, (_: Any) Escalate)
}
//#default-strategy-fallback
def receive = Actor.emptyBehavior
}
//#supervisor
//#child
class Child extends Actor {
var state = 0

View file

@ -72,6 +72,11 @@ exceptions are handled by default:
If the exception escalate all the way up to the root guardian it will handle it
in the same way as the default strategy defined above.
You can combine your own strategy with the default strategy:
.. includecode:: code/docs/actor/FaultHandlingDocSpec.scala
:include: default-strategy-fallback
Stopping Supervisor Strategy
^^^^^^^^^^^^^^^^^^^^^^^^^^^^