Adding internal api markers and other small corrections #26156

This commit is contained in:
Nicolas Vollmar 2019-01-15 21:34:11 +01:00
parent a8080a2140
commit 0abd8bab96
5 changed files with 31 additions and 22 deletions

View file

@ -6,15 +6,18 @@ package akka.pattern
import akka.actor.SupervisorStrategy._ import akka.actor.SupervisorStrategy._
import akka.actor.{ OneForOneStrategy, _ } import akka.actor.{ OneForOneStrategy, _ }
import akka.annotation.InternalApi
import scala.concurrent.duration._ import scala.concurrent.duration._
/** /**
* INTERNAL API
*
* Back-off supervisor that stops and starts a child actor when the child actor restarts. * Back-off supervisor that stops and starts a child actor when the child actor restarts.
* This back-off supervisor is created by using ``akka.pattern.BackoffSupervisor.props`` * This back-off supervisor is created by using ``akka.pattern.BackoffSupervisor.props``
* with ``akka.pattern.Backoff.onFailure``. * with ``akka.pattern.Backoff.onFailure``.
*/ */
private class BackoffOnRestartSupervisor( @InternalApi private class BackoffOnRestartSupervisor(
val childProps: Props, val childProps: Props,
val childName: String, val childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,

View file

@ -6,15 +6,18 @@ package akka.pattern
import akka.actor.SupervisorStrategy.{ Directive, Escalate } import akka.actor.SupervisorStrategy.{ Directive, Escalate }
import akka.actor.{ Actor, ActorLogging, OneForOneStrategy, Props, SupervisorStrategy, Terminated } import akka.actor.{ Actor, ActorLogging, OneForOneStrategy, Props, SupervisorStrategy, Terminated }
import akka.annotation.InternalApi
import scala.concurrent.duration.FiniteDuration import scala.concurrent.duration.FiniteDuration
/** /**
* INTERNAL API
*
* Back-off supervisor that stops and starts a child actor using a back-off algorithm when the child actor stops. * Back-off supervisor that stops and starts a child actor using a back-off algorithm when the child actor stops.
* This back-off supervisor is created by using `akka.pattern.BackoffSupervisor.props` * This back-off supervisor is created by using `akka.pattern.BackoffSupervisor.props`
* with `Backoff.onStop`. * with `Backoff.onStop`.
*/ */
private[akka] class BackoffOnStopSupervisor( @InternalApi private[akka] class BackoffOnStopSupervisor(
val childProps: Props, val childProps: Props,
val childName: String, val childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
@ -30,7 +33,6 @@ private[akka] class BackoffOnStopSupervisor(
import BackoffSupervisor._ import BackoffSupervisor._
import context.dispatcher import context.dispatcher
// to keep binary compatibility with 2.4.1
override val supervisorStrategy = strategy match { override val supervisorStrategy = strategy match {
case oneForOne: OneForOneStrategy case oneForOne: OneForOneStrategy
OneForOneStrategy(oneForOne.maxNrOfRetries, oneForOne.withinTimeRange, oneForOne.loggingEnabled) { OneForOneStrategy(oneForOne.maxNrOfRetries, oneForOne.withinTimeRange, oneForOne.loggingEnabled) {
@ -73,8 +75,9 @@ private[akka] class BackoffOnStopSupervisor(
protected def handleMessageToChild(msg: Any): Unit = child match { protected def handleMessageToChild(msg: Any): Unit = child match {
case Some(c) case Some(c)
c.forward(msg) c.forward(msg)
if (!finalStopMessageReceived && finalStopMessage.isDefined) { if (!finalStopMessageReceived) finalStopMessage match {
finalStopMessageReceived = finalStopMessage.get.apply(msg) case Some(fsm) finalStopMessageReceived = fsm(msg)
case None
} }
case None case None
replyWhileStopped match { replyWhileStopped match {

View file

@ -244,7 +244,7 @@ object Backoff {
* random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay.
* In order to skip this additional delay pass in `0`. * In order to skip this additional delay pass in `0`.
*/ */
@Deprecated @deprecated("Use the overloaded one which accepts maxNrOfRetries instead.", "2.5.17")
def onFailure( def onFailure(
childProps: Props, childProps: Props,
childName: String, childName: String,
@ -497,7 +497,7 @@ object Backoff {
* random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. * random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay.
* In order to skip this additional delay pass in `0`. * In order to skip this additional delay pass in `0`.
*/ */
@Deprecated @deprecated("Use the overloaded one which accepts maxNrOfRetries instead.", "2.5.17")
def onStop( def onStop(
childProps: Props, childProps: Props,
childName: String, childName: String,

View file

@ -16,7 +16,7 @@ import scala.util.Try
object BackoffSupervisor { object BackoffSupervisor {
/** /**
* Props for creating a [[BackoffSupervisor]] actor. * Props for creating a `BackoffSupervisor` actor.
* *
* Exceptions in the child are handled with the default supervision strategy, i.e. * Exceptions in the child are handled with the default supervision strategy, i.e.
* most exceptions will immediately restart the child. You can define another * most exceptions will immediately restart the child. You can define another
@ -42,7 +42,7 @@ object BackoffSupervisor {
} }
/** /**
* Props for creating a [[BackoffSupervisor]] actor. * Props for creating a `BackoffSupervisor` actor.
* *
* Exceptions in the child are handled with the default supervision strategy, i.e. * Exceptions in the child are handled with the default supervision strategy, i.e.
* most exceptions will immediately restart the child. You can define another * most exceptions will immediately restart the child. You can define another
@ -76,7 +76,7 @@ object BackoffSupervisor {
} }
/** /**
* Props for creating a [[BackoffSupervisor]] actor. * Props for creating a `BackoffSupervisor` actor.
* *
* Exceptions in the child are handled with the default supervision strategy, i.e. * Exceptions in the child are handled with the default supervision strategy, i.e.
* most exceptions will immediately restart the child. You can define another * most exceptions will immediately restart the child. You can define another
@ -102,7 +102,7 @@ object BackoffSupervisor {
} }
/** /**
* Props for creating a [[BackoffSupervisor]] actor. * Props for creating a `BackoffSupervisor` actor.
* *
* Exceptions in the child are handled with the default supervision strategy, i.e. * Exceptions in the child are handled with the default supervision strategy, i.e.
* most exceptions will immediately restart the child. You can define another * most exceptions will immediately restart the child. You can define another
@ -132,7 +132,7 @@ object BackoffSupervisor {
} }
/** /**
* Props for creating a [[BackoffSupervisor]] actor with a custom * Props for creating a `BackoffSupervisor` actor with a custom
* supervision strategy. * supervision strategy.
* *
* Exceptions in the child are handled with the given `supervisionStrategy`. A * Exceptions in the child are handled with the given `supervisionStrategy`. A
@ -166,7 +166,7 @@ object BackoffSupervisor {
} }
/** /**
* Props for creating a [[BackoffSupervisor]] actor with a custom * Props for creating a `BackoffSupervisor` actor with a custom
* supervision strategy. * supervision strategy.
* *
* Exceptions in the child are handled with the given `supervisionStrategy`. A * Exceptions in the child are handled with the given `supervisionStrategy`. A
@ -197,26 +197,26 @@ object BackoffSupervisor {
} }
/** /**
* Props for creating a [[BackoffSupervisor]] actor from [[BackoffOptions]]. * Props for creating a `BackoffSupervisor` actor from [[BackoffOptions]].
* *
* @param options the [[BackoffOptions]] that specify how to construct a backoff-supervisor. * @param options the [[BackoffOptions]] that specify how to construct a backoff-supervisor.
*/ */
def props(options: BackoffOptions): Props = options.props def props(options: BackoffOptions): Props = options.props
/** /**
* Send this message to the [[BackoffSupervisor]] and it will reply with * Send this message to the `BackoffSupervisor` and it will reply with
* [[BackoffSupervisor.CurrentChild]] containing the `ActorRef` of the current child, if any. * [[BackoffSupervisor.CurrentChild]] containing the `ActorRef` of the current child, if any.
*/ */
final case object GetCurrentChild final case object GetCurrentChild
/** /**
* Java API: Send this message to the [[BackoffSupervisor]] and it will reply with * Java API: Send this message to the `BackoffSupervisor` and it will reply with
* [[BackoffSupervisor.CurrentChild]] containing the `ActorRef` of the current child, if any. * [[BackoffSupervisor.CurrentChild]] containing the `ActorRef` of the current child, if any.
*/ */
def getCurrentChild = GetCurrentChild def getCurrentChild = GetCurrentChild
/** /**
* Send this message to the [[BackoffSupervisor]] and it will reply with * Send this message to the `BackoffSupervisor` and it will reply with
* [[BackoffSupervisor.CurrentChild]] containing the `ActorRef` of the current child, if any. * [[BackoffSupervisor.CurrentChild]] containing the `ActorRef` of the current child, if any.
*/ */
final case class CurrentChild(ref: Option[ActorRef]) { final case class CurrentChild(ref: Option[ActorRef]) {
@ -227,25 +227,25 @@ object BackoffSupervisor {
} }
/** /**
* Send this message to the [[BackoffSupervisor]] and it will reset the back-off. * Send this message to the `BackoffSupervisor` and it will reset the back-off.
* This should be used in conjunction with `withManualReset` in [[BackoffOptions]]. * This should be used in conjunction with `withManualReset` in [[BackoffOptions]].
*/ */
final case object Reset final case object Reset
/** /**
* Java API: Send this message to the [[BackoffSupervisor]] and it will reset the back-off. * Java API: Send this message to the `BackoffSupervisor` and it will reset the back-off.
* This should be used in conjunction with `withManualReset` in [[BackoffOptions]]. * This should be used in conjunction with `withManualReset` in [[BackoffOptions]].
*/ */
def reset = Reset def reset = Reset
/** /**
* Send this message to the [[BackoffSupervisor]] and it will reply with * Send this message to the `BackoffSupervisor` and it will reply with
* [[BackoffSupervisor.RestartCount]] containing the current restart count. * [[BackoffSupervisor.RestartCount]] containing the current restart count.
*/ */
final case object GetRestartCount final case object GetRestartCount
/** /**
* Java API: Send this message to the [[BackoffSupervisor]] and it will reply with * Java API: Send this message to the `BackoffSupervisor` and it will reply with
* [[BackoffSupervisor.RestartCount]] containing the current restart count. * [[BackoffSupervisor.RestartCount]] containing the current restart count.
*/ */
def getRestartCount = GetRestartCount def getRestartCount = GetRestartCount

View file

@ -5,11 +5,14 @@
package akka.pattern package akka.pattern
import akka.actor.{ Actor, ActorRef, Props } import akka.actor.{ Actor, ActorRef, Props }
import akka.annotation.InternalApi
/** /**
* INTERNAL API
*
* Implements basic backoff handling for [[BackoffOnRestartSupervisor]] and [[BackoffOnStopSupervisor]]. * Implements basic backoff handling for [[BackoffOnRestartSupervisor]] and [[BackoffOnStopSupervisor]].
*/ */
private[akka] trait HandleBackoff { @InternalApi private[akka] trait HandleBackoff {
this: Actor this: Actor
def childProps: Props def childProps: Props
def childName: String def childName: String