case class AllForOneStrategy(maxNrOfRetries: Int = -1, withinTimeRange: Duration = Duration.Inf, loggingEnabled: Boolean = true)(decider: Decider) extends SupervisorStrategy with Product with Serializable
Applies the fault handling Directive
(Resume, Restart, Stop) specified in the Decider
to all children when one fails, as opposed to pekko.actor.OneForOneStrategy that applies
it only to the child actor that failed.
- 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
- withinTimeRange
duration of the time window for maxNrOfRetries, Duration.Inf means no window
- loggingEnabled
the strategy logs the failure if this is enabled (true), by default it is enabled
- decider
mapping from Throwable to pekko.actor.SupervisorStrategy.Directive, you can also use a scala.collection.immutable.Seq of Throwables which maps the given Throwables to restarts, otherwise escalates.
- Source
- FaultHandling.scala
- Alphabetic
- By Inheritance
- AllForOneStrategy
- Serializable
- Product
- Equals
- SupervisorStrategy
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new AllForOneStrategy(decider: Decider)
Java API: compatible with lambda expressions
- new AllForOneStrategy(loggingEnabled: Boolean, decider: Decider)
Java API: compatible with lambda expressions
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, decider: Decider)
Java API: compatible with lambda expressions
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, decider: Decider)
Java API: compatible with lambda expressions
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, trapExit: Iterable[Class[_ <: Throwable]])
Java API
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, trapExit: Iterable[Class[_ <: Throwable]])
Java API
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, decider: JDecider)
Java API
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, decider: JDecider)
Java API
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, decider: JDecider, loggingEnabled: Boolean)
Java API
- new AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Duration, decider: JDecider, loggingEnabled: Boolean)
Java API
- new AllForOneStrategy(maxNrOfRetries: Int = -1, withinTimeRange: Duration = Duration.Inf, loggingEnabled: Boolean = true)(decider: Decider)
- 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
- withinTimeRange
duration of the time window for maxNrOfRetries, Duration.Inf means no window
- loggingEnabled
the strategy logs the failure if this is enabled (true), by default it is enabled
- decider
mapping from Throwable to pekko.actor.SupervisorStrategy.Directive, you can also use a scala.collection.immutable.Seq of Throwables which maps the given Throwables to restarts, otherwise escalates.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toany2stringadd[AllForOneStrategy] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (AllForOneStrategy, B)
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toArrowAssoc[AllForOneStrategy] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- val decider: Decider
Returns the Decider that is associated with this SupervisorStrategy.
Returns the Decider that is associated with this SupervisorStrategy. The Decider is invoked by the default implementation of
handleFailure
to obtain the Directive to be applied.- Definition Classes
- AllForOneStrategy → SupervisorStrategy
- def ensuring(cond: (AllForOneStrategy) => Boolean, msg: => Any): AllForOneStrategy
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toEnsuring[AllForOneStrategy] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (AllForOneStrategy) => Boolean): AllForOneStrategy
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toEnsuring[AllForOneStrategy] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): AllForOneStrategy
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toEnsuring[AllForOneStrategy] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): AllForOneStrategy
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toEnsuring[AllForOneStrategy] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def handleChildTerminated(context: ActorContext, child: ActorRef, children: Iterable[ActorRef]): Unit
This method is called after the child has been removed from the set of children.
This method is called after the child has been removed from the set of children. It does not need to do anything special. Exceptions thrown from this method do NOT make the actor fail if this happens during termination.
- Definition Classes
- AllForOneStrategy → SupervisorStrategy
- def handleFailure(context: ActorContext, child: ActorRef, cause: Throwable, stats: ChildRestartStats, children: Iterable[ChildRestartStats]): Boolean
This is the main entry point: in case of a child’s failure, this method must try to handle the failure by resuming, restarting or stopping the child (and returning
true
), or it returnsfalse
to escalate the failure, which will lead to this actor re-throwing the exception which caused the failure.This is the main entry point: in case of a child’s failure, this method must try to handle the failure by resuming, restarting or stopping the child (and returning
true
), or it returnsfalse
to escalate the failure, which will lead to this actor re-throwing the exception which caused the failure. The exception will not be wrapped.This method calls pekko.actor.SupervisorStrategy#logFailure, which will log the failure unless it is escalated. You can customize the logging by setting pekko.actor.SupervisorStrategy#loggingEnabled to
false
and do the logging inside thedecider
or override thelogFailure
method.- children
is a lazy collection (a view)
- Definition Classes
- SupervisorStrategy
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def logFailure(context: ActorContext, child: ActorRef, cause: Throwable, decision: Directive): Unit
Default logging of actor failures when pekko.actor.SupervisorStrategy#loggingEnabled is
true
.Default logging of actor failures when pekko.actor.SupervisorStrategy#loggingEnabled is
true
.Escalate
failures are not logged here, since they are supposed to be handled at a level higher up in the hierarchy.Resume
failures are logged atWarning
level.Stop
andRestart
failures are logged atError
level.- Definition Classes
- SupervisorStrategy
- val loggingEnabled: Boolean
Logging of actor failures is done when this is
true
.Logging of actor failures is done when this is
true
.- Definition Classes
- AllForOneStrategy → SupervisorStrategy
- val maxNrOfRetries: Int
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def processFailure(context: ActorContext, restart: Boolean, child: ActorRef, cause: Throwable, stats: ChildRestartStats, children: Iterable[ChildRestartStats]): Unit
This method is called to act on the failure of a child: restart if the flag is true, stop otherwise.
This method is called to act on the failure of a child: restart if the flag is true, stop otherwise.
- Definition Classes
- AllForOneStrategy → SupervisorStrategy
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- final def restartChild(child: ActorRef, cause: Throwable, suspendFirst: Boolean): Unit
Restart the given child, possibly suspending it first.
Restart the given child, possibly suspending it first.
IMPORTANT:
If the child is the currently failing one, it will already have been suspended, hence
suspendFirst
must be false. If the child is not the currently failing one, then it did not request this treatment and is therefore not prepared to be resumed without prior suspend.- Definition Classes
- SupervisorStrategy
- final def resumeChild(child: ActorRef, cause: Throwable): Unit
Resume the previously failed child: do never apply this to a child which is not the currently failing child.
Resume the previously failed child: do never apply this to a child which is not the currently failing child. Suspend/resume needs to be done in matching pairs, otherwise actors will wake up too soon or never at all.
- Definition Classes
- SupervisorStrategy
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- val withinTimeRange: Duration
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toStringFormat[AllForOneStrategy] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (AllForOneStrategy, B)
- Implicit
- This member is added by an implicit conversion from AllForOneStrategy toArrowAssoc[AllForOneStrategy] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.