=doc #3531 Recommend orElse’ing super.supervisorStrategy.decider
This commit is contained in:
parent
822f80bc69
commit
0d859f1424
2 changed files with 23 additions and 0 deletions
|
|
@ -63,6 +63,24 @@ object FaultHandlingDocSpec {
|
||||||
}
|
}
|
||||||
//#supervisor2
|
//#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
|
//#child
|
||||||
class Child extends Actor {
|
class Child extends Actor {
|
||||||
var state = 0
|
var state = 0
|
||||||
|
|
|
||||||
|
|
@ -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
|
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.
|
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
|
Stopping Supervisor Strategy
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue