Skip to content

Commit

Permalink
Added healtcheck package for Hazelcast Xabaril#810
Browse files Browse the repository at this point in the history
  • Loading branch information
alesebi91 authored and alessandro.zani committed Dec 13, 2023
1 parent 7060bdd commit 68f6156
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 15 deletions.
44 changes: 29 additions & 15 deletions AspNetCore.Diagnostics.HealthChecks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.AzureDigitalTw
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Aws.Sqs", "src\HealthChecks.Aws.Sqs\HealthChecks.Aws.Sqs.csproj", "{3E28B63C-814E-46C9-ADBF-7357997148F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HealthChecks.AzureApplicationInsights", "src\HealthChecks.AzureApplicationInsights\HealthChecks.AzureApplicationInsights.csproj", "{97C43FFC-0A48-47C7-93EE-7382C2989AAE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.AzureApplicationInsights", "src\HealthChecks.AzureApplicationInsights\HealthChecks.AzureApplicationInsights.csproj", "{97C43FFC-0A48-47C7-93EE-7382C2989AAE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HealthChecks.AzureApplicationInsights.Tests", "test\HealthChecks.AzureApplicationInsights.Tests\HealthChecks.AzureApplicationInsights.Tests.csproj", "{78902D9E-CD1A-4FB7-B752-A3471A2DD457}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.AzureApplicationInsights.Tests", "test\HealthChecks.AzureApplicationInsights.Tests\HealthChecks.AzureApplicationInsights.Tests.csproj", "{78902D9E-CD1A-4FB7-B752-A3471A2DD457}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Aws.Sqs.Tests", "test\HealthChecks.Aws.Sqs.Tests\HealthChecks.Aws.Sqs.Tests.csproj", "{EFA76A2C-CA0E-42BC-8215-AEEB16414947}"
EndProject
Expand Down Expand Up @@ -283,11 +283,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.UI.Data.Tests"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Dapr", "src\HealthChecks.Dapr\HealthChecks.Dapr.csproj", "{716C2E59-6BB4-49A1-B685-9958B7EF0F3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HealthChecks.Dapr.Tests", "test\HealthChecks.Dapr.Tests\HealthChecks.Dapr.Tests.csproj", "{1C2085FA-2D33-459B-945E-337323485E16}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Dapr.Tests", "test\HealthChecks.Dapr.Tests\HealthChecks.Dapr.Tests.csproj", "{1C2085FA-2D33-459B-945E-337323485E16}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HealthChecks.Azure.KeyVault.Secrets", "src\HealthChecks.Azure.KeyVault.Secrets\HealthChecks.Azure.KeyVault.Secrets.csproj", "{877E2C7C-F136-4DC7-882D-C1ADE6B5E3ED}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Azure.KeyVault.Secrets", "src\HealthChecks.Azure.KeyVault.Secrets\HealthChecks.Azure.KeyVault.Secrets.csproj", "{877E2C7C-F136-4DC7-882D-C1ADE6B5E3ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HealthChecks.Azure.KeyVault.Secrets.Tests", "test\HealthChecks.Azure.KeyVault.Secrets.Tests\HealthChecks.Azure.KeyVault.Secrets.Tests.csproj", "{B664ADD4-7067-4CCE-BBAC-146A174A7F73}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Azure.KeyVault.Secrets.Tests", "test\HealthChecks.Azure.KeyVault.Secrets.Tests\HealthChecks.Azure.KeyVault.Secrets.Tests.csproj", "{B664ADD4-7067-4CCE-BBAC-146A174A7F73}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Hazelcast", "src\HealthChecks.Hazelcast\HealthChecks.Hazelcast.csproj", "{4F89E1D6-B9A0-4C7A-B3BF-2948A613A489}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HealthChecks.Hazelcast.Tests", "test\HealthChecks.Hazelcast.Tests\HealthChecks.Hazelcast.Tests.csproj", "{419BAB71-82A1-4931-B581-F01C306EBC3F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -719,18 +723,18 @@ Global
{7052C706-4B1A-4167-A33A-DF3E9FBCFE6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7052C706-4B1A-4167-A33A-DF3E9FBCFE6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7052C706-4B1A-4167-A33A-DF3E9FBCFE6B}.Release|Any CPU.Build.0 = Release|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Release|Any CPU.Build.0 = Release|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Release|Any CPU.Build.0 = Release|Any CPU
{3E28B63C-814E-46C9-ADBF-7357997148F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E28B63C-814E-46C9-ADBF-7357997148F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E28B63C-814E-46C9-ADBF-7357997148F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E28B63C-814E-46C9-ADBF-7357997148F5}.Release|Any CPU.Build.0 = Release|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97C43FFC-0A48-47C7-93EE-7382C2989AAE}.Release|Any CPU.Build.0 = Release|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78902D9E-CD1A-4FB7-B752-A3471A2DD457}.Release|Any CPU.Build.0 = Release|Any CPU
{EFA76A2C-CA0E-42BC-8215-AEEB16414947}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFA76A2C-CA0E-42BC-8215-AEEB16414947}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFA76A2C-CA0E-42BC-8215-AEEB16414947}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -807,6 +811,14 @@ Global
{B664ADD4-7067-4CCE-BBAC-146A174A7F73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B664ADD4-7067-4CCE-BBAC-146A174A7F73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B664ADD4-7067-4CCE-BBAC-146A174A7F73}.Release|Any CPU.Build.0 = Release|Any CPU
{4F89E1D6-B9A0-4C7A-B3BF-2948A613A489}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F89E1D6-B9A0-4C7A-B3BF-2948A613A489}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F89E1D6-B9A0-4C7A-B3BF-2948A613A489}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F89E1D6-B9A0-4C7A-B3BF-2948A613A489}.Release|Any CPU.Build.0 = Release|Any CPU
{419BAB71-82A1-4931-B581-F01C306EBC3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{419BAB71-82A1-4931-B581-F01C306EBC3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{419BAB71-82A1-4931-B581-F01C306EBC3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{419BAB71-82A1-4931-B581-F01C306EBC3F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -918,9 +930,9 @@ Global
{FF492215-60BC-40C6-B118-D22DF9063547} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{247EF2E5-F4B9-47D4-BB89-27860DF53D5F} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{7052C706-4B1A-4167-A33A-DF3E9FBCFE6B} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{78902D9E-CD1A-4FB7-B752-A3471A2DD457} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{97C43FFC-0A48-47C7-93EE-7382C2989AAE} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{3E28B63C-814E-46C9-ADBF-7357997148F5} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{97C43FFC-0A48-47C7-93EE-7382C2989AAE} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{78902D9E-CD1A-4FB7-B752-A3471A2DD457} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{EFA76A2C-CA0E-42BC-8215-AEEB16414947} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{AE41DB38-93BC-48A7-8841-163E5E13CE8D} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{CB1A7B68-E24A-4729-9401-606F3A914586} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
Expand All @@ -940,6 +952,8 @@ Global
{1C2085FA-2D33-459B-945E-337323485E16} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{877E2C7C-F136-4DC7-882D-C1ADE6B5E3ED} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{B664ADD4-7067-4CCE-BBAC-146A174A7F73} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
{4F89E1D6-B9A0-4C7A-B3BF-2948A613A489} = {2A3FD988-2BB8-43CF-B3A2-B70E648259D4}
{419BAB71-82A1-4931-B581-F01C306EBC3F} = {FF4414C2-8863-4ADA-8A1D-4B9F25C361FE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B8C62A1-11B6-469F-874C-A02443256568}
Expand Down
2 changes: 2 additions & 0 deletions Nuget.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
<add key="NugetorgProxy" value="https://nexus.cariprpc.it/repository/nuget.org-proxy/index.json" />
</packageSources>
</configuration>
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ HealthChecks packages include health checks for:
| Google Cloud Firestore | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.Gcp.CloudFirestore)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Gcp.CloudFirestore) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.Gcp.CloudFirestore)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Gcp.CloudFirestore) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/cloudfirestore)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/cloudfirestore)
| Gremlin | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.Gremlin)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Gremlin) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.Gremlin)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Gremlin) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/gremlin)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/gremlin)
| Hangfire | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.Hangfire)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Hangfire) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.Hangfire)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Hangfire) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/hangfire)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/hangfire)
| Hazelcast | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.Hazelcast)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Hazelcast) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.Hazelcast)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Hazelcast) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/hazelcast)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/hazelcast)
| IbmMQ | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.IbmMQ)](https://www.nuget.org/packages/AspNetCore.HealthChecks.IbmMQ) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.IbmMQ)](https://www.nuget.org/packages/AspNetCore.HealthChecks.IbmMQ) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/ibmmq)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/ibmmq)
| InfluxDB | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.InfluxDB)](https://www.nuget.org/packages/AspNetCore.HealthChecks.InfluxDB) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.InfluxDB)](https://www.nuget.org/packages/AspNetCore.HealthChecks.InfluxDB) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/influxdb)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/influxdb)
| Kafka | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.HealthChecks.Kafka)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Kafka) | [![Nuget](https://img.shields.io/nuget/v/AspNetCore.HealthChecks.Kafka)](https://www.nuget.org/packages/AspNetCore.HealthChecks.Kafka) | [![view](https://img.shields.io/github/issues/Xabaril/AspNetCore.Diagnostics.HealthChecks/kafka)](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/labels/kafka)
Expand Down Expand Up @@ -141,6 +142,7 @@ Install-Package AspNetCore.HealthChecks.EventStore.gRPC
Install-Package AspNetCore.HealthChecks.Gcp.CloudFirestore
Install-Package AspNetCore.HealthChecks.Gremlin
Install-Package AspNetCore.HealthChecks.Hangfire
Install-Package AspNetCore.HealthChecks.Hazelcast
Install-Package AspNetCore.HealthChecks.IbmMQ
Install-Package AspNetCore.HealthChecks.InfluxDB
Install-Package AspNetCore.HealthChecks.Kafka
Expand Down
1 change: 1 addition & 0 deletions build/versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<HealthCheckEventStore>7.0.0</HealthCheckEventStore>
<HealthCheckGremlin>7.0.0</HealthCheckGremlin>
<HealthCheckHangfire>7.0.0</HealthCheckHangfire>
<HealthCheckHazelcast>7.0.0</HealthCheckHazelcast>
<HealthCheckIbmMQ>7.0.0</HealthCheckIbmMQ>
<HealthCheckInfluxDB>7.0.0</HealthCheckInfluxDB>
<HealthCheckIoTHub>7.0.0</HealthCheckIoTHub>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using HealthChecks.Hazelcast;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Extension methods to configure <see cref="HazelcastHealthCheck"/>.
/// </summary>
public static class HazelcastHealthCheckBuilderExtensions
{
/// <summary>
/// Add a health check for Hazelcast.
/// </summary>
/// <param name="builder">The <see cref="IHealthChecksBuilder"/>.</param>
/// <param name="setup">Action to configure <see cref="HazelcastHealthCheckOptions"/></param>
/// <param name="name">The health check name. Optional. If <c>null</c> the type name 'hazelcast' will be used for the name.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
/// </param>
/// <param name="tags">A list of tags that can be used to filter sets of health checks. Optional.</param>
/// <param name="timeout">An optional <see cref="TimeSpan"/> representing the timeout of the check.</param>
/// <returns></returns>
public static IHealthChecksBuilder AddHazelcast(
this IHealthChecksBuilder builder,
Action<HazelcastHealthCheckOptions> setup,
string? name = default,
HealthStatus failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
var options = new HazelcastHealthCheckOptions();
setup?.Invoke(options);

return builder.Add(new HealthCheckRegistration(
name ?? "hazelcast",
_ => new HazelcastHealthCheck(options),
failureStatus,
tags,
timeout));
}

/// <summary>
/// Add a health check for Hazelcast.
/// </summary>
/// <param name="builder">The <see cref="IHealthChecksBuilder"/>.</param>
/// <param name="options">Options for health check.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the type name 'hazelcast' will be used for the name.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
/// </param>
/// <param name="tags">A list of tags that can be used to filter sets of health checks. Optional.</param>
/// <param name="timeout">An optional <see cref="TimeSpan"/> representing the timeout of the check.</param>
/// <returns></returns>
public static IHealthChecksBuilder AddHazelcast(
this IHealthChecksBuilder builder,
HazelcastHealthCheckOptions options,
string? name = default,
HealthStatus failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
Guard.ThrowIfNull(options);

return builder.Add(new HealthCheckRegistration(
name ?? "hazelcast",
_ => new HazelcastHealthCheck(options),
failureStatus,
tags,
timeout));
}
}
50 changes: 50 additions & 0 deletions src/HealthChecks.Hazelcast/HazelcastHealthCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Hazelcast;
using Hazelcast.Networking;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace HealthChecks.Hazelcast;

/// <summary>
/// A health check for Hazelcast services.
/// </summary>
public class HazelcastHealthCheck : IHealthCheck
{
private readonly HazelcastHealthCheckOptions _options;

public HazelcastHealthCheck(HazelcastHealthCheckOptions options)
{
_ = Guard.ThrowIfNull(options);
_ = Guard.ThrowIfNull(options.ConnectionHost, true);

_options = options;
if (string.IsNullOrEmpty(_options.ClientName))
{
_options.ClientName = $"HazelcastHealthcheck_{Environment.MachineName}";
}
}

/// <inheritdoc />
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
await using var client = await HazelcastClientFactory.StartNewClientAsync(options =>
{
options.Networking.Addresses.Add(_options.ConnectionHost);
options.Networking.ReconnectMode = ReconnectMode.DoNotReconnect;
options.Networking.ConnectionTimeoutMilliseconds = (int)_options.ConnectionTimeout.TotalMilliseconds;

options.ClusterName = _options.ClusterName;
options.ClientName = _options.ClientName;
}, cancellationToken).ConfigureAwait(false);

return client.IsActive && client.IsConnected
? HealthCheckResult.Healthy()
: new HealthCheckResult(context.Registration.FailureStatus, description: $"Hazelcast client connection failed: {client.State}");
}
catch (Exception ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}
27 changes: 27 additions & 0 deletions src/HealthChecks.Hazelcast/HazelcastHealthCheckOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace HealthChecks.Hazelcast;

/// <summary>
/// Options for <see cref="HazelcastHealthCheck"/>.
/// </summary>
public class HazelcastHealthCheckOptions
{
/// <summary>
/// Hazelcast connection host ({ip/DNS}:{port})
/// </summary>
public string ConnectionHost { get; set; } = null!;

/// <summary>
/// Hazelcast cluster name to connect
/// </summary>
public string ClusterName { get; set; } = "dev";

/// <summary>
/// Hazelcast connection client name (use to track the healthcheck connection to your Hazelcast)
/// </summary>
public string ClientName { get; set; } = null!;

/// <summary>
/// Hazelcast client connection timeout
/// </summary>
public TimeSpan ConnectionTimeout { get; set; } = TimeSpan.FromMilliseconds(100);
}
15 changes: 15 additions & 0 deletions src/HealthChecks.Hazelcast/HealthChecks.Hazelcast.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageTags>$(PackageTags);Hazelcast</PackageTags>
<Description>HealthChecks.Hazelcast is the health check package for Hazelcast.</Description>
<VersionPrefix>$(HealthCheckHazelcast)</VersionPrefix>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hazelcast.Net" Version="5.3.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.9" />
</ItemGroup>

</Project>
Loading

0 comments on commit 68f6156

Please sign in to comment.