Search Results for

    Show / Hide Table of Contents

    Class SupervisorStrategy

    Base class for supervision strategies

    Inheritance
    object
    SupervisorStrategy
    AllForOneStrategy
    OneForOneStrategy
    DelegatingSupervisorStrategy
    Implements
    ISurrogated
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Actor
    Assembly: Akka.dll
    Syntax
    public abstract class SupervisorStrategy : ISurrogated

    Fields

    | Edit this page View Source

    DefaultDecider

    When supervisorStrategy is not specified for an actor this Decider is used by default in the supervisor strategy. The child will be stopped when ActorInitializationException, ActorKilledException, or DeathPactException is thrown. It will be restarted for other Exception types. The error is escalated if it's a Exception, i.e. Error.

    Declaration
    public static IDecider DefaultDecider
    Field Value
    Type Description
    IDecider

    Directive.

    | Edit this page View Source

    DefaultStrategy

    When supervisorStrategy is not specified for an actor this is used by default. OneForOneStrategy with decider defined in DefaultDecider.

    Declaration
    public static readonly SupervisorStrategy DefaultStrategy
    Field Value
    Type Description
    SupervisorStrategy
    | Edit this page View Source

    StoppingStrategy

    This strategy resembles Erlang in that failing children are always terminated (one-for-one).

    Declaration
    public static readonly OneForOneStrategy StoppingStrategy
    Field Value
    Type Description
    OneForOneStrategy

    Properties

    | Edit this page View Source

    Decider

    TBD

    Declaration
    public abstract IDecider Decider { get; }
    Property Value
    Type Description
    IDecider
    | Edit this page View Source

    LoggingEnabled

    Determines if failures are logged

    Declaration
    protected bool LoggingEnabled { get; set; }
    Property Value
    Type Description
    bool

    Methods

    | Edit this page View Source

    Handle(IActorRef, Exception)

    Determines which Directive this strategy uses to handle exception that occur in the child actor.

    Declaration
    protected abstract Directive Handle(IActorRef child, Exception exception)
    Parameters
    Type Name Description
    IActorRef child

    The child actor where the exception occurred.

    Exception exception

    The exception that was thrown.

    Returns
    Type Description
    Directive

    The directive used to handle the exception.

    | Edit this page View Source

    HandleChildTerminated(IActorContext, IActorRef, IEnumerable<IInternalActorRef>)

    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.

    Declaration
    public abstract void HandleChildTerminated(IActorContext actorContext, IActorRef child, IEnumerable<IInternalActorRef> children)
    Parameters
    Type Name Description
    IActorContext actorContext

    TBD

    IActorRef child

    TBD

    IEnumerable<IInternalActorRef> children

    TBD

    | Edit this page View Source

    HandleFailure(ActorCell, IActorRef, Exception, ChildRestartStats, IReadOnlyCollection<ChildRestartStats>)

    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 returns false 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 SupervisorStrategy, which will log the failure unless it is escalated. You can customize the logging by setting SupervisorStrategy to false and do the logging inside the decider or override the LogFailure method.

    Declaration
    public bool HandleFailure(ActorCell actorCell, IActorRef child, Exception cause, ChildRestartStats stats, IReadOnlyCollection<ChildRestartStats> children)
    Parameters
    Type Name Description
    ActorCell actorCell

    The actor cell.

    IActorRef child

    The child actor.

    Exception cause

    The cause.

    ChildRestartStats stats

    The stats for the failed child.

    IReadOnlyCollection<ChildRestartStats> children

    TBD

    Returns
    Type Description
    bool

    true if the child actor was handled, otherwise false.

    | Edit this page View Source

    LogFailure(IActorContext, IActorRef, Exception, Directive)

    Logs the failure.

    Declaration
    protected virtual void LogFailure(IActorContext context, IActorRef child, Exception cause, Directive directive)
    Parameters
    Type Name Description
    IActorContext context

    The actor cell.

    IActorRef child

    The child.

    Exception cause

    The cause.

    Directive directive

    The directive.

    | Edit this page View Source

    ProcessFailure(IActorContext, bool, IActorRef, Exception, ChildRestartStats, IReadOnlyCollection<ChildRestartStats>)

    This method is called to act on the failure of a child: restart if the flag is true, stop otherwise.

    Declaration
    public abstract void ProcessFailure(IActorContext context, bool restart, IActorRef child, Exception cause, ChildRestartStats stats, IReadOnlyCollection<ChildRestartStats> children)
    Parameters
    Type Name Description
    IActorContext context

    The actor context.

    bool restart

    if set to true restart, stop otherwise.

    IActorRef child

    The child actor

    Exception cause

    The exception that caused the child to fail.

    ChildRestartStats stats

    The stats for the child that failed. The ActorRef to the child can be obtained via the Child property

    IReadOnlyCollection<ChildRestartStats> children

    The stats for all children

    | Edit this page View Source

    RestartChild(IActorRef, Exception, bool)

    Restarts the child.

    Declaration
    protected void RestartChild(IActorRef child, Exception cause, bool suspendFirst)
    Parameters
    Type Name Description
    IActorRef child

    The child.

    Exception cause

    The cause.

    bool suspendFirst

    if set to true [suspend first].

    | Edit this page View Source

    ResumeChild(IActorRef, Exception)

    Resumes the previously failed child. Suspend/resume needs to be done in matching pairs, otherwise actors will wake up too soon or never at all.

    note

    Never apply this to a child which is not the currently failing child.

    Declaration
    protected void ResumeChild(IActorRef child, Exception exception)
    Parameters
    Type Name Description
    IActorRef child

    The child actor that is being resumed.

    Exception exception

    The exception that caused the child actor to fail.

    | Edit this page View Source

    ToSurrogate(ActorSystem)

    Creates a surrogate representation of the current SupervisorStrategy.

    Declaration
    public abstract ISurrogate ToSurrogate(ActorSystem system)
    Parameters
    Type Name Description
    ActorSystem system

    The actor system that owns this router.

    Returns
    Type Description
    ISurrogate

    The surrogate representation of the current SupervisorStrategy.

    Implements

    ISurrogated

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET