64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using Akka.Actor;
|
|
using Akka.Cluster;
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Host.Health;
|
|
|
|
public sealed class AkkaClusterHealthCheck : IHealthCheck
|
|
{
|
|
private readonly ActorSystem _system;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the AkkaClusterHealthCheck class.
|
|
/// </summary>
|
|
/// <param name="system">The Akka actor system to check cluster health for.</param>
|
|
public AkkaClusterHealthCheck(ActorSystem system)
|
|
{
|
|
_system = system;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks the health of the Akka cluster asynchronously.
|
|
/// </summary>
|
|
/// <param name="context">The health check context.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
|
{
|
|
var cluster = Akka.Cluster.Cluster.Get(_system);
|
|
var selfUp = cluster.State.Members.Any(m =>
|
|
m.Address == cluster.SelfAddress && m.Status == MemberStatus.Up);
|
|
|
|
return Task.FromResult(selfUp
|
|
? HealthCheckResult.Healthy($"Self Up; {cluster.State.Members.Count} member(s)")
|
|
: HealthCheckResult.Degraded("Self not yet Up in cluster"));
|
|
}
|
|
}
|