Adding maximum restart attempts to BackoffSupervisor #24769

This commit is contained in:
Saleh Khazaei 2018-09-14 16:52:52 +04:30 committed by Patrik Nordwall
parent 0d7419b422
commit 176b718b2a
11 changed files with 475 additions and 39 deletions

View file

@ -23,7 +23,8 @@ class BackoffSupervisorDocSpec {
childName = "myEcho",
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2 // adds 20% "noise" to vary the intervals slightly
randomFactor = 0.2, // adds 20% "noise" to vary the intervals slightly
maxNrOfRetries = -1
))
system.actorOf(supervisor, name = "echoSupervisor")
@ -43,7 +44,8 @@ class BackoffSupervisorDocSpec {
childName = "myEcho",
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2 // adds 20% "noise" to vary the intervals slightly
randomFactor = 0.2, // adds 20% "noise" to vary the intervals slightly
maxNrOfRetries = -1
))
system.actorOf(supervisor, name = "echoSupervisor")
@ -63,7 +65,8 @@ class BackoffSupervisorDocSpec {
childName = "myEcho",
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2 // adds 20% "noise" to vary the intervals slightly
randomFactor = 0.2, // adds 20% "noise" to vary the intervals slightly
maxNrOfRetries = -1
).withManualReset // the child must send BackoffSupervisor.Reset to its parent
.withDefaultStoppingStrategy // Stop at any Exception thrown
)
@ -85,7 +88,8 @@ class BackoffSupervisorDocSpec {
childName = "myEcho",
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2 // adds 20% "noise" to vary the intervals slightly
randomFactor = 0.2, // adds 20% "noise" to vary the intervals slightly
maxNrOfRetries = -1
).withAutoReset(10.seconds) // reset if the child does not throw any errors within 10 seconds
.withSupervisorStrategy(
OneForOneStrategy() {

View file

@ -103,7 +103,8 @@ object PersistenceDocSpec {
childName = "myActor",
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2))
randomFactor = 0.2,
maxNrOfRetries = -1))
context.actorOf(props, name = "mySupervisor")
//#backoff
}