Improving documentation and code style #26156

This commit is contained in:
Nicolas Vollmar 2018-12-21 19:06:30 +01:00
parent 551bbdec77
commit a8080a2140
4 changed files with 14 additions and 15 deletions

View file

@ -78,15 +78,12 @@ private[akka] class BackoffOnStopSupervisor(
}
case None
replyWhileStopped match {
case None context.system.deadLetters.forward(msg)
case Some(r) sender() ! r
case None context.system.deadLetters.forward(msg)
}
finalStopMessage match {
case None
case Some(fsm)
if (fsm(msg)) {
context.stop(self)
}
case Some(fsm) if fsm(msg) context.stop(self)
case _
}
}
}

View file

@ -552,8 +552,9 @@ trait BackoffOptions {
* Returns a new BackoffOptions with a maximum number of retries to restart the child actor.
* By default, the supervisor will retry infinitely.
* With this option, the supervisor will terminate itself after the maxNoOfRetries is reached.
* @param maxNrOfRetries the number of times a child actor is allowed to be restarted, negative value means no limit,
* if the limit is exceeded the child actor is stopped
* @param maxNrOfRetries the number of times a child actor is allowed to be restarted.
* If negative, the value is unbounded, otherwise the provided
* limit is used. If the limit is exceeded the child actor will be stopped.
*/
def withMaxNrOfRetries(maxNrOfRetries: Int): BackoffOptions

View file

@ -278,7 +278,7 @@ object BackoffSupervisor {
}
// for backwards compability
@deprecated("Use BackoffSupervisor props method instead", since = "2.5.20")
@deprecated("Use `BackoffSupervisor.props` method instead", since = "2.5.20")
final class BackoffSupervisor(
override val childProps: Props,
override val childName: String,

View file

@ -6,6 +6,9 @@ package akka.pattern
import akka.actor.{ Actor, ActorRef, Props }
/**
* Implements basic backoff handling for [[BackoffOnRestartSupervisor]] and [[BackoffOnStopSupervisor]].
*/
private[akka] trait HandleBackoff {
this: Actor
def childProps: Props
@ -22,18 +25,16 @@ private[akka] trait HandleBackoff {
override def preStart(): Unit = startChild()
def startChild(): Unit = {
if (child.isEmpty) {
child = Some(context.watch(context.actorOf(childProps, childName)))
}
def startChild(): Unit = if (child.isEmpty) {
child = Some(context.watch(context.actorOf(childProps, childName)))
}
def handleBackoff: Receive = {
def handleBackoff: Actor.Receive = {
case StartChild
startChild()
reset match {
case AutoReset(resetBackoff)
val _ = context.system.scheduler.scheduleOnce(resetBackoff, self, ResetRestartCount(restartCount))
context.system.scheduler.scheduleOnce(resetBackoff, self, ResetRestartCount(restartCount))
case _ // ignore
}