Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace Akka.Persistence.Hosting
where TAdapter : Akka.Persistence.Journal.IReadEventAdapter { }
public Akka.Persistence.Hosting.AkkaPersistenceJournalBuilder AddWriteEventAdapter<TAdapter>(string eventAdapterName, System.Collections.Generic.IEnumerable<System.Type> boundTypes)
where TAdapter : Akka.Persistence.Journal.IWriteEventAdapter { }
public Akka.Persistence.Hosting.AkkaPersistenceJournalBuilder WithHealthCheck(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus unHealthyStatus = 1, string? name = null) { }
public Akka.Persistence.Hosting.AkkaPersistenceJournalBuilder WithHealthCheck(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus unHealthyStatus = 1, string? name = null, System.Collections.Generic.IEnumerable<string>? tags = null) { }
}
public sealed class AkkaPersistenceSnapshotBuilder
{
public AkkaPersistenceSnapshotBuilder(string snapshotStoreId, Akka.Hosting.AkkaConfigurationBuilder builder) { }
public Akka.Persistence.Hosting.AkkaPersistenceSnapshotBuilder WithHealthCheck(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus unHealthyStatus = 1, string? name = null) { }
public Akka.Persistence.Hosting.AkkaPersistenceSnapshotBuilder WithHealthCheck(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus unHealthyStatus = 1, string? name = null, System.Collections.Generic.IEnumerable<string>? tags = null) { }
}
public static class Extensions
{
Expand Down
14 changes: 9 additions & 5 deletions src/Akka.Persistence.Hosting/AkkaPersistenceHostingExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Akka.Configuration;
using Akka.Hosting;
Expand Down Expand Up @@ -52,11 +53,13 @@ public AkkaPersistenceJournalBuilder(string journalId, AkkaConfigurationBuilder
/// <param name="unHealthyStatus">Default status to return when the plugin reports <see cref="PersistenceHealthStatus.Unhealthy"/>
/// or <see cref="PersistenceHealthStatus.Degraded"/>. Defaults to degraded.</param>
/// <param name="name">Optional name to add to the health check.</param>
/// <returns></returns>
/// <param name="tags">Custom tags for the health check. If null, defaults to ["akka", "persistence", "journal"].</param>
/// <returns>The current builder instance for method chaining.</returns>
public AkkaPersistenceJournalBuilder WithHealthCheck(HealthStatus unHealthyStatus = HealthStatus.Degraded,
string? name = null)
string? name = null,
IEnumerable<string>? tags = null)
{
var registration = AddHealthCheck(name, unHealthyStatus);
var registration = AddHealthCheck(name, unHealthyStatus, tags);
HealthCheckRegistration = registration;
return this;
}
Expand Down Expand Up @@ -96,14 +99,15 @@ private void AddAdapter<TAdapter>(string eventAdapterName, IEnumerable<Type> bou
}
}

private AkkaHealthCheckRegistration AddHealthCheck(string? name, HealthStatus unHealthyStatus)
private AkkaHealthCheckRegistration AddHealthCheck(string? name, HealthStatus unHealthyStatus, IEnumerable<string>? tags = null)
{
var pluginId = $"akka.persistence.journal.{JournalId}";
var healthCheckTags = tags?.ToList() ?? new List<string> { "akka", "persistence", "journal" };
var registration = new AkkaHealthCheckRegistration(
name ?? $"Akka.Persistence.Journal.{JournalId}",
new JournalHealthCheck(pluginId),
unHealthyStatus,
["akka", "persistence", "journal"]);
healthCheckTags);
return registration;
}

Expand Down
13 changes: 9 additions & 4 deletions src/Akka.Persistence.Hosting/SnapshotOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Akka.Configuration;
using Akka.Hosting;
Expand Down Expand Up @@ -33,23 +35,26 @@ public AkkaPersistenceSnapshotBuilder(string snapshotStoreId, AkkaConfigurationB
/// <param name="unHealthyStatus">Default status to return when the plugin reports <see cref="PersistenceHealthStatus.Unhealthy"/>
/// or <see cref="PersistenceHealthStatus.Degraded"/>. Defaults to degraded.</param>
/// <param name="name">Optional name to add to the health check.</param>
/// <param name="tags">Custom tags for the health check. If null, defaults to ["akka", "persistence", "snapshot-store"].</param>
/// <returns>The current builder instance for method chaining.</returns>
public AkkaPersistenceSnapshotBuilder WithHealthCheck(HealthStatus unHealthyStatus = HealthStatus.Degraded,
string? name = null)
string? name = null,
IEnumerable<string>? tags = null)
{
var registration = AddHealthCheck(name, unHealthyStatus);
var registration = AddHealthCheck(name, unHealthyStatus, tags);
HealthCheckRegistration = registration;
return this;
}

private AkkaHealthCheckRegistration AddHealthCheck(string? name, HealthStatus unHealthyStatus)
private AkkaHealthCheckRegistration AddHealthCheck(string? name, HealthStatus unHealthyStatus, IEnumerable<string>? tags = null)
{
var pluginId = $"akka.persistence.snapshot-store.{SnapshotStoreId}";
var healthCheckTags = tags?.ToList() ?? new List<string> { "akka", "persistence", "snapshot-store" };
var registration = new AkkaHealthCheckRegistration(
name ?? $"Akka.Persistence.SnapshotStore.{SnapshotStoreId}",
new SnapshotStoreHealthCheck(pluginId),
unHealthyStatus,
["akka", "persistence", "snapshot-store"]);
healthCheckTags);
return registration;
}

Expand Down