Skip to content

Commit

Permalink
Add Cluster.Sharding journal migration adapter convernience method (#226
Browse files Browse the repository at this point in the history
)

* Add Cluster.Sharding journal migration adapter convernience method

* Update API Verify list
  • Loading branch information
Arkatufus authored Feb 17, 2023
1 parent 93d3ed1 commit 2013abd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace Akka.Persistence.Hosting
{
public static class AkkaPersistenceHostingExtensions
{
public static Akka.Hosting.AkkaConfigurationBuilder WithClusterShardingJournalMigrationAdapter(this Akka.Hosting.AkkaConfigurationBuilder builder, Akka.Persistence.Hosting.JournalOptions journalOptions) { }
public static Akka.Hosting.AkkaConfigurationBuilder WithClusterShardingJournalMigrationAdapter(this Akka.Hosting.AkkaConfigurationBuilder builder, string journalId) { }
public static Akka.Hosting.AkkaConfigurationBuilder WithInMemoryJournal(this Akka.Hosting.AkkaConfigurationBuilder builder) { }
public static Akka.Hosting.AkkaConfigurationBuilder WithInMemoryJournal(this Akka.Hosting.AkkaConfigurationBuilder builder, System.Action<Akka.Persistence.Hosting.AkkaPersistenceJournalBuilder> journalBuilder, string journalId = "inmem", bool isDefaultPlugin = true) { }
public static Akka.Hosting.AkkaConfigurationBuilder WithInMemorySnapshotStore(this Akka.Hosting.AkkaConfigurationBuilder builder, string snapshotStoreId = "inmem", bool isDefaultPlugin = true) { }
Expand Down
34 changes: 34 additions & 0 deletions src/Akka.Persistence.Hosting/AkkaPersistenceHostingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,39 @@ class = ""Akka.Persistence.Snapshot.MemorySnapshotStore, Akka.Persistence""

return builder.AddHocon(liveConfig, HoconAddMode.Prepend);
}

/// <summary>
/// Adds the Akka.NET v1.4 to v1.5 Akka.Cluster.Sharding persistence event migration adapter to a journal.
/// </summary>
/// <param name="builder">The builder instance being configured.</param>
/// <param name="journalOptions">The specific journal options instance used by Akka.Cluster.Sharding persistence. For example, an instance of <c>SqlServerJournalOptions</c></param>
/// <returns>The same <see cref="AkkaConfigurationBuilder"/> instance originally passed in.</returns>
public static AkkaConfigurationBuilder WithClusterShardingJournalMigrationAdapter(
this AkkaConfigurationBuilder builder,
JournalOptions journalOptions)
=> builder.WithClusterShardingJournalMigrationAdapter(journalOptions.PluginId);

/// <summary>
/// Adds the Akka.NET v1.4 to v1.5 Akka.Cluster.Sharding persistence event migration adapter to a journal.
/// </summary>
/// <param name="builder">The builder instance being configured.</param>
/// <param name="journalId">The specific journal identifier used by Akka.Cluster.Sharding persistence. For example, "akka.persistence.journal.sql-server"</param>
/// <returns>The same <see cref="AkkaConfigurationBuilder"/> instance originally passed in.</returns>
public static AkkaConfigurationBuilder WithClusterShardingJournalMigrationAdapter(
this AkkaConfigurationBuilder builder,
string journalId)
{
var config = @$"{journalId} {{
event-adapters {{
coordinator-migration = ""Akka.Cluster.Sharding.OldCoordinatorStateMigrationEventAdapter, Akka.Cluster.Sharding""
}}
event-adapter-bindings {{
""Akka.Cluster.Sharding.ShardCoordinator+IDomainEvent, Akka.Cluster.Sharding"" = coordinator-migration
}}
}}";
return builder.AddHocon(config, HoconAddMode.Prepend);
}

}
}

0 comments on commit 2013abd

Please sign in to comment.