Removes stopping strategy from failure options #26156
This commit is contained in:
parent
9233ff5a40
commit
54232d785a
2 changed files with 12 additions and 9 deletions
|
|
@ -273,12 +273,6 @@ private[akka] sealed trait ExtendedBackoffOptions[T <: ExtendedBackoffOptions[T]
|
|||
*/
|
||||
def withSupervisorStrategy(supervisorStrategy: OneForOneStrategy): T
|
||||
|
||||
/**
|
||||
* Returns a new BackoffOptions with a default `SupervisorStrategy.stoppingStrategy`.
|
||||
* The default supervisor strategy is used as fallback for throwables not handled by `SupervisorStrategy.stoppingStrategy`.
|
||||
*/
|
||||
def withDefaultStoppingStrategy: T
|
||||
|
||||
/**
|
||||
* Returns a new BackoffOptions with a maximum number of retries to restart the child actor.
|
||||
* By default, the supervisor will retry infinitely.
|
||||
|
|
@ -309,6 +303,12 @@ private[akka] sealed trait ExtendedBackoffOptions[T <: ExtendedBackoffOptions[T]
|
|||
@DoNotInherit
|
||||
sealed trait BackoffOnStopOptions extends ExtendedBackoffOptions[BackoffOnStopOptions] {
|
||||
|
||||
/**
|
||||
* Returns a new BackoffOptions with a default `SupervisorStrategy.stoppingStrategy`.
|
||||
* The default supervisor strategy is used as fallback for throwables not handled by `SupervisorStrategy.stoppingStrategy`.
|
||||
*/
|
||||
def withDefaultStoppingStrategy: BackoffOnStopOptions
|
||||
|
||||
/**
|
||||
* Predicate evaluated for each message, if it returns true and the supervised actor is
|
||||
* stopped then the supervisor will stop its self. If it returns true while
|
||||
|
|
@ -335,12 +335,15 @@ private final case class BackoffOnStopOptionsImpl[T](
|
|||
|
||||
private val backoffReset = reset.getOrElse(AutoReset(minBackoff))
|
||||
|
||||
// default
|
||||
def withAutoReset(resetBackoff: FiniteDuration) = copy(reset = Some(AutoReset(resetBackoff)))
|
||||
def withManualReset = copy(reset = Some(ManualReset))
|
||||
def withSupervisorStrategy(supervisorStrategy: OneForOneStrategy) = copy(supervisorStrategy = supervisorStrategy)
|
||||
def withDefaultStoppingStrategy = copy(supervisorStrategy = OneForOneStrategy(supervisorStrategy.maxNrOfRetries)(SupervisorStrategy.stoppingStrategy.decider))
|
||||
def withReplyWhileStopped(replyWhileStopped: Any) = copy(replyWhileStopped = Some(replyWhileStopped))
|
||||
def withMaxNrOfRetries(maxNrOfRetries: Int) = copy(supervisorStrategy = supervisorStrategy.withMaxNrOfRetries(maxNrOfRetries))
|
||||
|
||||
// additional
|
||||
def withDefaultStoppingStrategy = copy(supervisorStrategy = OneForOneStrategy(supervisorStrategy.maxNrOfRetries)(SupervisorStrategy.stoppingStrategy.decider))
|
||||
def withFinalStopMessage(action: Any ⇒ Boolean) = copy(finalStopMessage = Some(action))
|
||||
|
||||
def props: Props = {
|
||||
|
|
@ -370,10 +373,10 @@ private final case class BackoffOnFailureOptionsImpl[T](
|
|||
|
||||
private val backoffReset = reset.getOrElse(AutoReset(minBackoff))
|
||||
|
||||
// default
|
||||
def withAutoReset(resetBackoff: FiniteDuration) = copy(reset = Some(AutoReset(resetBackoff)))
|
||||
def withManualReset = copy(reset = Some(ManualReset))
|
||||
def withSupervisorStrategy(supervisorStrategy: OneForOneStrategy) = copy(supervisorStrategy = supervisorStrategy)
|
||||
def withDefaultStoppingStrategy = copy(supervisorStrategy = OneForOneStrategy(supervisorStrategy.maxNrOfRetries)(SupervisorStrategy.stoppingStrategy.decider))
|
||||
def withReplyWhileStopped(replyWhileStopped: Any) = copy(replyWhileStopped = Some(replyWhileStopped))
|
||||
def withMaxNrOfRetries(maxNrOfRetries: Int) = copy(supervisorStrategy = supervisorStrategy.withMaxNrOfRetries(maxNrOfRetries))
|
||||
|
||||
|
|
|
|||
|
|
@ -265,11 +265,11 @@ Options are:
|
|||
* `withAutoReset`: The backoff is reset if no failure/stop occurs within the duration. This is the default behaviour with `minBackoff` as default value
|
||||
* `withManualReset`: The child must send `BackoffSupervisor.Reset` to its backoff supervisor (parent)
|
||||
* `withSupervisionStrategy`: Sets a custom `OneForOneStrategy` (as each backoff supervisor only has one child). The default strategy uses the `akka.actor.SupervisorStrategy.defaultDecider` which restarts on exceptions.
|
||||
* `withDefaultStoppingStrategy`: Sets a `OneForOneStrategy` with the stopping decider that stops the child on all exceptions.
|
||||
* `withMaxNrOfRetries`: Sets the maximum number of retries until the supervisor will give up (`-1` is default which means no limit of retries). Note: This is set on the supervision strategy, so setting a different strategy resets the `maxNrOfRetries`.
|
||||
* `withReplyWhileStopped`: By default all messages received while the child is stopped are forwarded to dead letters. With this set, the supervisor will reply to the sender instead.
|
||||
|
||||
Only available on `BackoffOnStopOptions`:
|
||||
* `withDefaultStoppingStrategy`: Sets a `OneForOneStrategy` with the stopping decider that stops the child on all exceptions.
|
||||
* `withFinalStopMessage`: Allows to define a predicate to decide on finally stopping the child (and supervisor). Used for passivate sharded actors - see above.
|
||||
|
||||
Some examples:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue