diff --git a/src/Akka.Hosting.API.Tests/verify/CoreApiSpec.ApprovePersistence.verified.txt b/src/Akka.Hosting.API.Tests/verify/CoreApiSpec.ApprovePersistence.verified.txt index ba336a8b..8b5415eb 100644 --- a/src/Akka.Hosting.API.Tests/verify/CoreApiSpec.ApprovePersistence.verified.txt +++ b/src/Akka.Hosting.API.Tests/verify/CoreApiSpec.ApprovePersistence.verified.txt @@ -38,6 +38,7 @@ namespace Akka.Persistence.Hosting public bool IsDefaultPlugin { get; set; } public string PluginId { get; } public string? Serializer { get; set; } + public Akka.Actor.SupervisorStrategyConfigurator? SupervisorStrategy { get; set; } public abstract string Identifier { get; set; } protected virtual System.Text.StringBuilder Build(System.Text.StringBuilder sb) { } public Akka.Configuration.Config ToConfig() { } @@ -58,6 +59,7 @@ namespace Akka.Persistence.Hosting public bool IsDefaultPlugin { get; set; } public string PluginId { get; } public string? Serializer { get; set; } + public Akka.Actor.SupervisorStrategyConfigurator? SupervisorStrategy { get; set; } public abstract string Identifier { get; set; } protected virtual System.Text.StringBuilder Build(System.Text.StringBuilder sb) { } public Akka.Configuration.Config ToConfig() { } diff --git a/src/Akka.Persistence.Hosting/JournalOptions.cs b/src/Akka.Persistence.Hosting/JournalOptions.cs index 086fbaba..deb9520f 100644 --- a/src/Akka.Persistence.Hosting/JournalOptions.cs +++ b/src/Akka.Persistence.Hosting/JournalOptions.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Akka.Actor; using Akka.Annotations; using Akka.Configuration; using Akka.Hosting; @@ -53,6 +54,17 @@ protected JournalOptions(bool isDefault) /// public string? Serializer { get; set; } + /// + /// + /// Supervisor strategy for the journal actor. + /// It needs to be a subclass of Akka.Actor.SupervisorStrategyConfigurator and have a parameterless constructor. + /// + /// + /// By default, it restarts the journal when it crashed. + /// + /// + public SupervisorStrategyConfigurator? SupervisorStrategy { get; set; } + /// /// /// The default configuration for this journal. This must be the actual configuration block for this journal. @@ -102,6 +114,10 @@ protected virtual StringBuilder Build(StringBuilder sb) sb.Insert(0, $"{PluginId} {{{Environment.NewLine}"); sb.AppendLine($"auto-initialize = {AutoInitialize.ToHocon()}"); sb.AppendLine($"serializer = {Serializer.ToHocon()}"); + + if (SupervisorStrategy is not null) + sb.AppendLine($"supervisor-strategy = {SupervisorStrategy.GetType().AssemblyQualifiedName.ToHocon()}"); + Adapters.AppendAdapters(sb); sb.AppendLine("}"); diff --git a/src/Akka.Persistence.Hosting/SnapshotOptions.cs b/src/Akka.Persistence.Hosting/SnapshotOptions.cs index c8c008ab..036f4920 100644 --- a/src/Akka.Persistence.Hosting/SnapshotOptions.cs +++ b/src/Akka.Persistence.Hosting/SnapshotOptions.cs @@ -6,6 +6,7 @@ using System; using System.Text; +using Akka.Actor; using Akka.Configuration; using Akka.Hosting; @@ -48,6 +49,17 @@ protected SnapshotOptions(bool isDefault) /// public string? Serializer { get; set; } + /// + /// + /// Supervisor strategy for the snapshot-store actor. + /// It needs to be a subclass of Akka.Actor.SupervisorStrategyConfigurator and have a parameterless constructor. + /// + /// + /// By default, it restarts the snapshot-store when it crashed. + /// + /// + public SupervisorStrategyConfigurator? SupervisorStrategy { get; set; } + /// /// /// The default configuration for this snapshot store. This must be the actual configuration block for this journal. @@ -91,6 +103,10 @@ protected virtual StringBuilder Build(StringBuilder sb) sb.Insert(0, $"{PluginId} {{{Environment.NewLine}"); sb.AppendLine($"serializer = {Serializer.ToHocon()}"); sb.AppendLine($"auto-initialize = {AutoInitialize.ToHocon()}"); + + if (SupervisorStrategy is not null) + sb.AppendLine($"supervisor-strategy = {SupervisorStrategy.GetType().AssemblyQualifiedName.ToHocon()}"); + sb.AppendLine("}"); if (IsDefaultPlugin)