Merge pull request #250 from jboner/wip-1714-withinTimeRange-patriknw
Improved API of OneForOneStrategy and AllForOneStrategy. See #1714
This commit is contained in:
commit
dcdbca1167
23 changed files with 192 additions and 162 deletions
|
|
@ -20,13 +20,14 @@ object FaultHandlingDocSpec {
|
|||
//#strategy
|
||||
import akka.actor.OneForOneStrategy
|
||||
import akka.actor.SupervisorStrategy._
|
||||
import akka.util.duration._
|
||||
|
||||
override val supervisorStrategy = OneForOneStrategy({
|
||||
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
|
||||
case _: ArithmeticException ⇒ Resume
|
||||
case _: NullPointerException ⇒ Restart
|
||||
case _: IllegalArgumentException ⇒ Stop
|
||||
case _: Exception ⇒ Escalate
|
||||
}: Decider, maxNrOfRetries = Some(10), withinTimeRange = Some(60000))
|
||||
}
|
||||
//#strategy
|
||||
|
||||
def receive = {
|
||||
|
|
@ -40,13 +41,14 @@ object FaultHandlingDocSpec {
|
|||
//#strategy2
|
||||
import akka.actor.OneForOneStrategy
|
||||
import akka.actor.SupervisorStrategy._
|
||||
import akka.util.duration._
|
||||
|
||||
override val supervisorStrategy = OneForOneStrategy({
|
||||
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
|
||||
case _: ArithmeticException ⇒ Resume
|
||||
case _: NullPointerException ⇒ Restart
|
||||
case _: IllegalArgumentException ⇒ Stop
|
||||
case _: Exception ⇒ Escalate
|
||||
}: Decider, maxNrOfRetries = Some(10), withinTimeRange = Some(60000))
|
||||
}
|
||||
//#strategy2
|
||||
|
||||
def receive = {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ that the respective limit does not apply, leaving the possibility to specify an
|
|||
absolute upper limit on the restarts or to make the restarts work infinitely.
|
||||
|
||||
The match statement which forms the bulk of the body is of type ``Decider``,
|
||||
which is a ``PartialFunction[Throwable, Action]``, and we need to help out the
|
||||
type inferencer a bit here by ascribing that type after the closing brace. This
|
||||
which is a ``PartialFunction[Throwable, Action]``. This
|
||||
is the piece which maps child failure types to their corresponding actions.
|
||||
|
||||
Practical Application
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue