Skip to content

Commit

Permalink
Add missing settings in Hosting extension method (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Apr 11, 2023
1 parent 5fb3de6 commit 6311090
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Akka.Persistence.Sql.Hosting/SqlJournalOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using Akka.Hosting;
using Akka.Persistence.Hosting;
using Akka.Persistence.Sql.Config;

namespace Akka.Persistence.Sql.Hosting
{
Expand Down Expand Up @@ -67,6 +68,19 @@ public SqlJournalOptions(bool isDefaultPlugin, string identifier = "sql") : base
/// </summary>
public JournalDatabaseOptions? DatabaseOptions { get; set; }

/// <summary>
/// <para>
/// Describe how tags are being stored inside the database. Setting this to
/// <see cref="TagMode.Csv"/> will store the tags as a comma delimited value
/// in a column named <c>tags</c> inside the event journal. Setting this to
/// <see cref="TagMode.TagTable"/> will store the tags inside a separate
/// tag table instead.
/// </para>
/// <b>NOTE</b>: This is used primarily for backward compatibility,
/// you leave this empty for greenfield projects.
/// </summary>
public TagMode? TagStorageMode { get; set; }

protected override Configuration.Config InternalDefaultConfig => Default;

protected override StringBuilder Build(StringBuilder sb)
Expand All @@ -79,6 +93,9 @@ protected override StringBuilder Build(StringBuilder sb)

sb.AppendLine($"connection-string = {ConnectionString.ToHocon()}");
sb.AppendLine($"provider-name = {ProviderName.ToHocon()}");

if (TagStorageMode is { })
sb.AppendLine($"tag-write-mode = {TagStorageMode.ToString().ToHocon()}");

if (DatabaseOptions is { })
sb.AppendLine($"table-mapping = {DatabaseOptions.Mapping.Name().ToHocon()}");
Expand All @@ -87,6 +104,17 @@ protected override StringBuilder Build(StringBuilder sb)

base.Build(sb);

if (IsDefaultPlugin)
{
sb.AppendLine("akka.persistence.query.journal.sql {");
sb.AppendLine($"connection-string = {ConnectionString.ToHocon()}");
sb.AppendLine($"provider-name = {ProviderName.ToHocon()}");

if (TagStorageMode is { })
sb.AppendLine($"tag-read-mode = {TagStorageMode.ToString().ToHocon()}");
sb.AppendLine("}");
}

if(QueryRefreshInterval is { })
sb.AppendLine($"akka.persistence.query.journal.sql.refresh-interval = {QueryRefreshInterval.ToHocon()}");

Expand Down

0 comments on commit 6311090

Please sign in to comment.