Class CoordinatedShutdown
An ActorSystem extension used to help coordinate and sequence shutdown activities during graceful termination of actor systems, plugins, and so forth.
Implements
Inherited Members
Namespace: Akka.Actor
Assembly: Akka.dll
Syntax
public sealed class CoordinatedShutdown : IExtension
Fields
| Improve this Doc View SourcePhaseActorSystemTerminate
Declaration
public const string PhaseActorSystemTerminate = "actor-system-terminate"
Field Value
Type | Description |
---|---|
String |
PhaseBeforeActorSystemTerminate
Declaration
public const string PhaseBeforeActorSystemTerminate = "before-actor-system-terminate"
Field Value
Type | Description |
---|---|
String |
PhaseBeforeClusterShutdown
Declaration
public const string PhaseBeforeClusterShutdown = "before-cluster-shutdown"
Field Value
Type | Description |
---|---|
String |
PhaseBeforeServiceUnbind
Declaration
public const string PhaseBeforeServiceUnbind = "before-service-unbind"
Field Value
Type | Description |
---|---|
String |
PhaseClusterExiting
Declaration
public const string PhaseClusterExiting = "cluster-exiting"
Field Value
Type | Description |
---|---|
String |
PhaseClusterExitingDone
Declaration
public const string PhaseClusterExitingDone = "cluster-exiting-done"
Field Value
Type | Description |
---|---|
String |
PhaseClusterLeave
Declaration
public const string PhaseClusterLeave = "cluster-leave"
Field Value
Type | Description |
---|---|
String |
PhaseClusterShardingShutdownRegion
Declaration
public const string PhaseClusterShardingShutdownRegion = "cluster-sharding-shutdown-region"
Field Value
Type | Description |
---|---|
String |
PhaseClusterShutdown
Declaration
public const string PhaseClusterShutdown = "cluster-shutdown"
Field Value
Type | Description |
---|---|
String |
PhaseServiceRequestsDone
Declaration
public const string PhaseServiceRequestsDone = "service-requests-done"
Field Value
Type | Description |
---|---|
String |
PhaseServiceStop
Declaration
public const string PhaseServiceStop = "service-stop"
Field Value
Type | Description |
---|---|
String |
PhaseServiceUnbind
Declaration
public const string PhaseServiceUnbind = "service-unbind"
Field Value
Type | Description |
---|---|
String |
Properties
| Improve this Doc View SourceShutdownReason
The CoordinatedShutdown.Reason for the shutdown as passed to the Run(CoordinatedShutdown.Reason, String) method. null if the shutdown has not been started.
Declaration
public CoordinatedShutdown.Reason ShutdownReason { get; }
Property Value
Type | Description |
---|---|
CoordinatedShutdown.Reason |
System
The ActorSystem
Declaration
public ExtendedActorSystem System { get; }
Property Value
Type | Description |
---|---|
ExtendedActorSystem |
TotalTimeout
The sum of timeouts of all phases that have some task.
Declaration
public TimeSpan TotalTimeout { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
| Improve this Doc View SourceAddTask(String, String, Func<Task<Done>>)
Add a task to a phase. It doesn't remove previously added tasks.
Tasks added to the same phase are executed in parallel without any ordering assumptions. Next phase will not start until all tasks of previous phase have completed.
Declaration
public void AddTask(string phase, string taskName, Func<Task<Done>> task)
Parameters
Type | Name | Description |
---|---|---|
String | phase | The phase to add this task to. |
String | taskName | The name of the task to add to this phase. |
Func<Task<Done>> | task | The delegate that produces a Task that will be executed. |
Remarks
Tasks should typically be registered as early as possible after system startup. When running the CoordinatedShutdown tasks that have been registered will be performed but tasks that are added too late will not be run.
It is possible to add a task to a later phase from within a task in an earlier phase and it will be performed.
Get(ActorSystem)
Retrieves the CoordinatedShutdown extension for the current ActorSystem
Declaration
public static CoordinatedShutdown Get(ActorSystem sys)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | sys | The current actor system. |
Returns
Type | Description |
---|---|
CoordinatedShutdown | A CoordinatedShutdown instance. |
Run(CoordinatedShutdown.Reason, String)
Run tasks of all phases including and after the given phase.
Declaration
public Task<Done> Run(CoordinatedShutdown.Reason reason, string fromPhase = null)
Parameters
Type | Name | Description |
---|---|---|
CoordinatedShutdown.Reason | reason | Reason of the shutdown |
String | fromPhase | Optional. The phase to start the run from. |
Returns
Type | Description |
---|---|
Task<Done> | A task that is completed when all such tasks have been completed, or there is failure when Akka.Actor.Phase.Recover is disabled. |
Remarks
It is safe to call this method multiple times. It will only run the shutdown sequence once.
Timeout(String)
The configured timeout for a given Akka.Actor.Phase.
Declaration
public TimeSpan Timeout(string phase)
Parameters
Type | Name | Description |
---|---|---|
String | phase | The name of the phase. |
Returns
Type | Description |
---|---|
TimeSpan | Returns the timeout if ti exists. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if |