diff --git a/README.md b/README.md
index a16ea5b034..163a6c6b7c 100644
--- a/README.md
+++ b/README.md
@@ -261,7 +261,7 @@ Check this [README](./AzureDevOpsTasks/README.md) on how to configure it.
AspNetCore.Diagnostics.HealthChecks wouldn't be possible without the time and effort of its contributors. The team is made up of Unai Zorrilla Castro [@unaizorrilla](https://github.com/unaizorrilla), Luis Ruiz Pavón [@lurumad](https://github.com/lurumad), Carlos Landeras [@carloslanderas](https://github.com/carloslanderas) and Eduard Tomás [@eiximenis](https://github.com/eiximenis).
-*Our valued committers are*: Hugo Biarge @hbiarge, Matt Channer @mattchanner, Luis Fraile @lfraile, Bradley Grainger @bgrainger, Simon Birrer @SbiCA, Mahamadou Camara @poumup,Jonathan Berube @joncloud, Daniel Edwards @dantheman999301, Mike McFarland @roketworks, Matteo @Franklin89, Miňo Martiniak @Burgyn, Peter Winkler @pajzo, @mikevanoo,Alexandru Rus @AlexandruRus23,Volker Thiel @riker09, Ahmad Magdy @Ahmad-Magdy, Marcel Lambacher @Marcel-Lambacher.
+*Our valued committers are*: Hugo Biarge @hbiarge, Matt Channer @mattchanner, Luis Fraile @lfraile, Bradley Grainger @bgrainger, Simon Birrer @SbiCA, Mahamadou Camara @poumup,Jonathan Berube @joncloud, Daniel Edwards @dantheman999301, Mike McFarland @roketworks, Matteo @Franklin89, Miňo Martiniak @Burgyn, Peter Winkler @pajzo, @mikevanoo,Alexandru Rus @AlexandruRus23,Volker Thiel @riker09, Ahmad Magdy @Ahmad-Magdy, Marcel Lambacher @Marcel-Lambacher,Ivan Maximov @sungam3r.
If you want to contribute to the project and make it better, your help is very welcome. You can contribute with helpful bug reports, features requests and also submitting new features with pull requests.
diff --git a/build.ps1 b/build.ps1
index 428d522e91..06219d6058 100644
--- a/build.ps1
+++ b/build.ps1
@@ -3,7 +3,7 @@
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
- to see if an error occcured. If an error is detected then an exception is thrown.
+ to see if an error occured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
@@ -22,7 +22,7 @@ function Exec
}
}
-if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
+if (Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
exec { & dotnet restore }
@@ -94,6 +94,7 @@ if ($suffix -eq "") {
exec { & dotnet pack .\src\HealthChecks.UI.Client\HealthChecks.UI.Client.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
exec { & dotnet pack .\src\HealthChecks.Publisher.ApplicationInsights\HealthChecks.Publisher.ApplicationInsights.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
exec { & dotnet pack .\src\HealthChecks.Publisher.Prometheus\HealthChecks.Publisher.Prometheus.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
+ exec { & dotnet pack .\src\HealthChecks.Publisher.Seq\HealthChecks.Publisher.Seq.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
exec { & dotnet pack .\src\HealthChecks.Consul\HealthChecks.Consul.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
exec { & dotnet pack .\src\HealthChecks.RavenDB\HealthChecks.RavenDB.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
exec { & dotnet pack .\src\HealthChecks.Kubernetes\HealthChecks.Kubernetes.csproj -c Release -o ..\..\artifacts --include-symbols --no-build }
@@ -128,6 +129,7 @@ else {
exec { & dotnet pack .\src\HealthChecks.UI.Client\HealthChecks.UI.Client.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
exec { & dotnet pack .\src\HealthChecks.Publisher.ApplicationInsights\HealthChecks.Publisher.ApplicationInsights.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
exec { & dotnet pack .\src\HealthChecks.Publisher.Prometheus\HealthChecks.Publisher.Prometheus.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
+ exec { & dotnet pack .\src\HealthChecks.Publisher.Seq\HealthChecks.Publisher.Seq.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
exec { & dotnet pack .\src\HealthChecks.Consul\HealthChecks.Consul.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
exec { & dotnet pack .\src\HealthChecks.RavenDB\HealthChecks.RavenDB.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
exec { & dotnet pack .\src\HealthChecks.Kubernetes\HealthChecks.Kubernetes.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix }
diff --git a/build/dependencies.props b/build/dependencies.props
index b7c4451327..a484e69e52 100644
--- a/build/dependencies.props
+++ b/build/dependencies.props
@@ -75,7 +75,7 @@
2.2.02.2.02.2.3
- 2.2.2
+ 2.2.32.2.12.2.12.2.1
@@ -99,7 +99,7 @@
2.2.02.2.02.2.2
- 2.2.0
+ 2.2.12.2.22.2.12.2.0
diff --git a/dotnet-install.ps1 b/dotnet-install.ps1
index 14ebe11af2..4e0543f8d2 100644
--- a/dotnet-install.ps1
+++ b/dotnet-install.ps1
@@ -48,7 +48,7 @@
.PARAMETER DryRun
If set it will not perform installation but instead display what command line to use to consistently install
currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link
- with specific version so that this command can be used deterministicly in a build script.
+ with specific version so that this command can be used deterministically in a build script.
It also displays binaries location if you prefer to install or download it yourself.
.PARAMETER NoPath
By default this script will set environment variable PATH for the current process to the binaries folder inside installation folder.
@@ -199,11 +199,11 @@ function GetHTTPResponse([Uri] $Uri)
# HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet.
Load-Assembly -Assembly System.Net.Http
- if(-not $ProxyAddress) {
+ if (-not $ProxyAddress) {
try {
# Despite no proxy being explicitly specified, we may still be behind a default proxy
$DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy;
- if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))) {
+ if ($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))) {
$ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString
$ProxyUseDefaultCredentials = $true
}
@@ -215,7 +215,7 @@ function GetHTTPResponse([Uri] $Uri)
}
}
- if($ProxyAddress) {
+ if ($ProxyAddress) {
$HttpClientHandler = New-Object System.Net.Http.HttpClientHandler
$HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials}
$HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler
diff --git a/samples/HealthChecks.Sample/Controllers/ValuesController.cs b/samples/HealthChecks.Sample/Controllers/ValuesController.cs
index 8540c5a3bf..3e09e93e8b 100644
--- a/samples/HealthChecks.Sample/Controllers/ValuesController.cs
+++ b/samples/HealthChecks.Sample/Controllers/ValuesController.cs
@@ -1,8 +1,5 @@
-using System;
+using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
namespace HealthChecks.Sample.Controllers
{
diff --git a/samples/HealthChecks.Sample/Program.cs b/samples/HealthChecks.Sample/Program.cs
index 582894f49c..b0d3a57424 100644
--- a/samples/HealthChecks.Sample/Program.cs
+++ b/samples/HealthChecks.Sample/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace HealthChecks.Sample
{
diff --git a/samples/HealthChecks.Sample/Startup.cs b/samples/HealthChecks.Sample/Startup.cs
index e5796629d3..29d6eaa15b 100644
--- a/samples/HealthChecks.Sample/Startup.cs
+++ b/samples/HealthChecks.Sample/Startup.cs
@@ -45,12 +45,12 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
- app.UseHealthChecks("/health", new HealthCheckOptions()
+ app.UseHealthChecks("/health", new HealthCheckOptions
{
Predicate = _ => true
});
- app.UseHealthChecks("/healthz", new HealthCheckOptions()
+ app.UseHealthChecks("/healthz", new HealthCheckOptions
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
diff --git a/samples/HealthChecks.UI.Sample/Program.cs b/samples/HealthChecks.UI.Sample/Program.cs
index 0834db4e08..73d51b5814 100644
--- a/samples/HealthChecks.UI.Sample/Program.cs
+++ b/samples/HealthChecks.UI.Sample/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace HealthChecks.UI.Sample
{
diff --git a/samples/HealthChecks.UI.Sample/Startup.cs b/samples/HealthChecks.UI.Sample/Startup.cs
index 7cfe2ded7b..78124785a7 100644
--- a/samples/HealthChecks.UI.Sample/Startup.cs
+++ b/samples/HealthChecks.UI.Sample/Startup.cs
@@ -1,10 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace HealthChecks.UI.Sample
diff --git a/samples/HealthChecks.UIAndApi/Program.cs b/samples/HealthChecks.UIAndApi/Program.cs
index eefc2b4385..efdc6f419c 100644
--- a/samples/HealthChecks.UIAndApi/Program.cs
+++ b/samples/HealthChecks.UIAndApi/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace HealthChecks.UIAndApi
{
diff --git a/samples/HealthChecks.UIAndApi/Startup.cs b/samples/HealthChecks.UIAndApi/Startup.cs
index 65d02b869e..76bd3ca36e 100644
--- a/samples/HealthChecks.UIAndApi/Startup.cs
+++ b/samples/HealthChecks.UIAndApi/Startup.cs
@@ -64,9 +64,9 @@ public void ConfigureServices(IServiceCollection services)
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
- app.UseHealthChecks("/healthz",new HealthCheckOptions()
+ app.UseHealthChecks("/healthz",new HealthCheckOptions
{
- Predicate = _=>true,
+ Predicate = _=> true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
})
.UseHealthChecksUI()
diff --git a/samples/HealthChecks.UIAndApiCustomization/Program.cs b/samples/HealthChecks.UIAndApiCustomization/Program.cs
index eefc2b4385..efdc6f419c 100644
--- a/samples/HealthChecks.UIAndApiCustomization/Program.cs
+++ b/samples/HealthChecks.UIAndApiCustomization/Program.cs
@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore;
+using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace HealthChecks.UIAndApi
{
diff --git a/samples/HealthChecks.UIAndApiCustomization/Startup.cs b/samples/HealthChecks.UIAndApiCustomization/Startup.cs
index 1c2c97a919..4d5ea81a25 100644
--- a/samples/HealthChecks.UIAndApiCustomization/Startup.cs
+++ b/samples/HealthChecks.UIAndApiCustomization/Startup.cs
@@ -36,7 +36,7 @@ public void ConfigureServices(IServiceCollection services)
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
- app.UseHealthChecks("/healthz", new HealthCheckOptions()
+ app.UseHealthChecks("/healthz", new HealthCheckOptions
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
diff --git a/src/HealthChecks.Aws.S3/S3HealthCheck.cs b/src/HealthChecks.Aws.S3/S3HealthCheck.cs
index 01fa6d8094..3e35aa374c 100644
--- a/src/HealthChecks.Aws.S3/S3HealthCheck.cs
+++ b/src/HealthChecks.Aws.S3/S3HealthCheck.cs
@@ -12,21 +12,22 @@ public class S3HealthCheck : IHealthCheck
private readonly S3BucketOptions _bucketOptions;
public S3HealthCheck(S3BucketOptions bucketOptions)
{
+ if (bucketOptions == null)
+ {
+ throw new ArgumentNullException(nameof(bucketOptions));
+ }
if (string.IsNullOrEmpty(bucketOptions.AccessKey))
{
throw new ArgumentNullException(nameof(S3BucketOptions.AccessKey));
}
-
if (string.IsNullOrEmpty(bucketOptions.SecretKey))
{
throw new ArgumentNullException(nameof(S3BucketOptions.SecretKey));
}
-
if (bucketOptions.S3Config == null)
{
throw new ArgumentNullException(nameof(S3BucketOptions.S3Config));
}
-
_bucketOptions = bucketOptions;
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
@@ -34,17 +35,17 @@ public async Task CheckHealthAsync(HealthCheckContext context
try
{
var credentials = new BasicAWSCredentials(_bucketOptions.AccessKey, _bucketOptions.SecretKey);
- var client = new AmazonS3Client(credentials, _bucketOptions.S3Config);
-
- var response = await client.ListObjectsAsync(_bucketOptions.BucketName, cancellationToken);
-
- if (_bucketOptions.CustomResponseCheck != null)
- {
- return _bucketOptions.CustomResponseCheck.Invoke(response)
- ? HealthCheckResult.Healthy()
- : new HealthCheckResult(context.Registration.FailureStatus, description:"Custom response check is not satisfied.");
+ using (var client = new AmazonS3Client(credentials, _bucketOptions.S3Config))
+ {
+ var response = await client.ListObjectsAsync(_bucketOptions.BucketName, cancellationToken);
+
+ if (_bucketOptions.CustomResponseCheck != null)
+ {
+ return _bucketOptions.CustomResponseCheck.Invoke(response)
+ ? HealthCheckResult.Healthy()
+ : new HealthCheckResult(context.Registration.FailureStatus, description: "Custom response check is not satisfied.");
+ }
}
-
return HealthCheckResult.Healthy();
}
catch (Exception ex)
diff --git a/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs b/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs
index d529b6168f..3c28bbec0b 100644
--- a/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs
+++ b/src/HealthChecks.AzureKeyVault/AzureKeyVaultHealthCheck.cs
@@ -11,7 +11,6 @@ namespace HealthChecks.AzureKeyVault
public class AzureKeyVaultHealthCheck : IHealthCheck
{
private readonly AzureKeyVaultOptions _options;
-
public AzureKeyVaultHealthCheck(AzureKeyVaultOptions options)
{
_options = options ?? throw new ArgumentNullException(nameof(options));
@@ -19,15 +18,15 @@ public AzureKeyVaultHealthCheck(AzureKeyVaultOptions options)
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
var currentSecret = string.Empty;
-
try
{
- var client = CreateClient();
- foreach (var item in _options.Secrets)
- {
- await client.GetSecretAsync(_options.KeyVaultUrlBase, item, cancellationToken);
+ using (var client = CreateClient())
+ {
+ foreach (var item in _options.Secrets)
+ {
+ await client.GetSecretAsync(_options.KeyVaultUrlBase, item, cancellationToken);
+ }
}
-
return HealthCheckResult.Healthy();
}
catch (Exception ex)
@@ -35,7 +34,6 @@ public async Task CheckHealthAsync(HealthCheckContext context
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
-
private KeyVaultClient CreateClient()
{
if (_options.UseManagedServiceIdentity)
@@ -48,7 +46,6 @@ private KeyVaultClient CreateClient()
return new KeyVaultClient(GetToken);
}
}
-
private async Task GetToken(string authority, string resource, string scope)
{
var authContext = new AuthenticationContext(authority);
@@ -59,7 +56,6 @@ private async Task GetToken(string authority, string resource, string sc
{
throw new InvalidOperationException($"[{nameof(AzureKeyVaultHealthCheck)}] - Failed to obtain the JWT token");
}
-
return result.AccessToken;
}
}
diff --git a/src/HealthChecks.AzureServiceBus/DependencyInjection/AzureServiceBusHealthCheckBuilderExtensions.cs b/src/HealthChecks.AzureServiceBus/DependencyInjection/AzureServiceBusHealthCheckBuilderExtensions.cs
index 17ac77f70f..fc5f730f0e 100644
--- a/src/HealthChecks.AzureServiceBus/DependencyInjection/AzureServiceBusHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.AzureServiceBus/DependencyInjection/AzureServiceBusHealthCheckBuilderExtensions.cs
@@ -31,7 +31,6 @@ public static IHealthChecksBuilder AddAzureEventHub(this IHealthChecksBuilder bu
failureStatus,
tags));
}
-
///
/// Add a health check for specified Azure Service Bus Queue.
///
@@ -48,12 +47,11 @@ public static IHealthChecksBuilder AddAzureEventHub(this IHealthChecksBuilder bu
public static IHealthChecksBuilder AddAzureServiceBusQueue(this IHealthChecksBuilder builder, string connectionString, string queueName, string name = default, HealthStatus? failureStatus = default, IEnumerable tags = default)
{
return builder.Add(new HealthCheckRegistration(
- name ?? AZUREQUEUE_NAME,
+ name ?? AZUREQUEUE_NAME,
sp => new AzureServiceBusQueueHealthCheck(connectionString, queueName),
failureStatus,
tags));
}
-
///
/// Add a health check for Azure Service Bus Topic.
///
@@ -70,7 +68,7 @@ public static IHealthChecksBuilder AddAzureServiceBusQueue(this IHealthChecksBui
public static IHealthChecksBuilder AddAzureServiceBusTopic(this IHealthChecksBuilder builder, string connectionString, string topicName, string name = default, HealthStatus? failureStatus = default, IEnumerable tags = default)
{
return builder.Add(new HealthCheckRegistration(
- name ?? AZURETOPIC_NAME,
+ name ?? AZURETOPIC_NAME,
sp => new AzureServiceBusTopicHealthCheck(connectionString, topicName),
failureStatus,
tags));
diff --git a/src/HealthChecks.AzureStorage/AzureBlobStorageHealthCheck.cs b/src/HealthChecks.AzureStorage/AzureBlobStorageHealthCheck.cs
index 2a1a683461..6b373676fd 100644
--- a/src/HealthChecks.AzureStorage/AzureBlobStorageHealthCheck.cs
+++ b/src/HealthChecks.AzureStorage/AzureBlobStorageHealthCheck.cs
@@ -7,12 +7,16 @@
namespace HealthChecks.AzureStorage
{
- public class AzureBlobStorageHealthCheck
+ public class AzureBlobStorageHealthCheck
: IHealthCheck
{
private readonly string _connectionString;
public AzureBlobStorageHealthCheck(string connectionString)
{
+ if (string.IsNullOrEmpty(connectionString))
+ {
+ throw new ArgumentNullException(nameof(connectionString));
+ }
_connectionString = connectionString;
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
diff --git a/src/HealthChecks.AzureStorage/AzureQueueStorageHealthCheck.cs b/src/HealthChecks.AzureStorage/AzureQueueStorageHealthCheck.cs
index b196f93ea3..066fc91e67 100644
--- a/src/HealthChecks.AzureStorage/AzureQueueStorageHealthCheck.cs
+++ b/src/HealthChecks.AzureStorage/AzureQueueStorageHealthCheck.cs
@@ -7,12 +7,16 @@
namespace HealthChecks.AzureStorage
{
- public class AzureQueueStorageHealthCheck
+ public class AzureQueueStorageHealthCheck
: IHealthCheck
{
private readonly string _connectionString;
public AzureQueueStorageHealthCheck(string connectionString)
{
+ if (string.IsNullOrEmpty(connectionString))
+ {
+ throw new ArgumentNullException(nameof(connectionString));
+ }
_connectionString = connectionString;
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
diff --git a/src/HealthChecks.AzureStorage/AzureTableStorageHealthCheck.cs b/src/HealthChecks.AzureStorage/AzureTableStorageHealthCheck.cs
index 9810161cc4..90905f866a 100644
--- a/src/HealthChecks.AzureStorage/AzureTableStorageHealthCheck.cs
+++ b/src/HealthChecks.AzureStorage/AzureTableStorageHealthCheck.cs
@@ -13,6 +13,10 @@ public class AzureTableStorageHealthCheck
private readonly string _connectionString;
public AzureTableStorageHealthCheck(string connectionString)
{
+ if (string.IsNullOrEmpty(connectionString))
+ {
+ throw new ArgumentNullException(nameof(connectionString));
+ }
_connectionString = connectionString;
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
diff --git a/src/HealthChecks.Consul/ConsulHealthCheck.cs b/src/HealthChecks.Consul/ConsulHealthCheck.cs
index 3c6792629b..7156b29318 100644
--- a/src/HealthChecks.Consul/ConsulHealthCheck.cs
+++ b/src/HealthChecks.Consul/ConsulHealthCheck.cs
@@ -14,15 +14,14 @@ public class ConsulHealthCheck : IHealthCheck
private readonly Func _httpClientFactory;
public ConsulHealthCheck(ConsulOptions options, Func httpClientFactory)
{
- _options = options;
- _httpClientFactory = httpClientFactory;
+ _options = options ?? throw new ArgumentNullException(nameof(options));
+ _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
var client = _httpClientFactory();
-
if (_options.RequireBasicAuthentication)
{
var credentials = ASCIIEncoding.ASCII.GetBytes($"{_options.Username}:{_options.Password}");
@@ -31,7 +30,6 @@ public async Task CheckHealthAsync(HealthCheckContext context
client.DefaultRequestHeaders
.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
}
-
var result = await client
.GetAsync($"{(_options.RequireHttps ? "https" : "http")}://{_options.HostName}:{_options.Port}/v1/status/leader", cancellationToken);
diff --git a/src/HealthChecks.Consul/DependencyInjection/ConsulHealthCheckBuilderExtensions.cs b/src/HealthChecks.Consul/DependencyInjection/ConsulHealthCheckBuilderExtensions.cs
index d4e19c6b0b..c888338b28 100644
--- a/src/HealthChecks.Consul/DependencyInjection/ConsulHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.Consul/DependencyInjection/ConsulHealthCheckBuilderExtensions.cs
@@ -9,7 +9,6 @@ namespace Microsoft.Extensions.DependencyInjection
public static class ConsulHealthCheckBuilderExtensions
{
private const string NAME = "consul";
-
///
/// Add a health check for Consul services.
///
@@ -31,14 +30,13 @@ public static IHealthChecksBuilder AddConsul(this IHealthChecksBuilder builder,
builder.Services.AddHttpClient();
var registrationName = name ?? NAME;
-
return builder.Add(new HealthCheckRegistration(
- name ?? NAME,
+ registrationName,
sp => CreateHealthCheck(sp, options, registrationName),
failureStatus,
tags));
}
- static ConsulHealthCheck CreateHealthCheck(IServiceProvider sp, ConsulOptions options, string name)
+ private static ConsulHealthCheck CreateHealthCheck(IServiceProvider sp, ConsulOptions options, string name)
{
var httpClientFactory = sp.GetRequiredService();
return new ConsulHealthCheck(options, () => httpClientFactory.CreateClient(name));
diff --git a/src/HealthChecks.CosmosDb/CosmosDbHealthCheck.cs b/src/HealthChecks.CosmosDb/CosmosDbHealthCheck.cs
index 6656364afa..df4634d866 100644
--- a/src/HealthChecks.CosmosDb/CosmosDbHealthCheck.cs
+++ b/src/HealthChecks.CosmosDb/CosmosDbHealthCheck.cs
@@ -13,7 +13,6 @@ public class CosmosDbHealthCheck
public CosmosDbHealthCheck(string connectionString)
{
_connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
-
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
diff --git a/src/HealthChecks.CosmosDb/DependencyInjection/CosmosDbHealthCheckBuilderExtensions.cs b/src/HealthChecks.CosmosDb/DependencyInjection/CosmosDbHealthCheckBuilderExtensions.cs
index c7087eeb2d..e13d91c1bc 100644
--- a/src/HealthChecks.CosmosDb/DependencyInjection/CosmosDbHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.CosmosDb/DependencyInjection/CosmosDbHealthCheckBuilderExtensions.cs
@@ -7,7 +7,6 @@ namespace Microsoft.Extensions.DependencyInjection
public static class CosmosDbHealthCheckBuilderExtensions
{
const string NAME = "cosmosdb";
-
///
/// Add a health check for Azure CosmosDb database.
///
diff --git a/src/HealthChecks.DocumentDb/DependencyInjection/DocumentDbHealthCheckBuilderExtensions.cs b/src/HealthChecks.DocumentDb/DependencyInjection/DocumentDbHealthCheckBuilderExtensions.cs
index ba4f603c2e..e5c1911568 100644
--- a/src/HealthChecks.DocumentDb/DependencyInjection/DocumentDbHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.DocumentDb/DependencyInjection/DocumentDbHealthCheckBuilderExtensions.cs
@@ -8,7 +8,6 @@ namespace Microsoft.Extensions.DependencyInjection
public static class DocumentDbHealthCheckBuilderExtensions
{
const string NAME = "documentdb";
-
///
/// Add a health check for Azure DocumentDb database.
///
diff --git a/src/HealthChecks.DocumentDb/DocumentDbHealthCheck.cs b/src/HealthChecks.DocumentDb/DocumentDbHealthCheck.cs
index f1b678a73f..40f416ab69 100644
--- a/src/HealthChecks.DocumentDb/DocumentDbHealthCheck.cs
+++ b/src/HealthChecks.DocumentDb/DocumentDbHealthCheck.cs
@@ -23,7 +23,7 @@ public async Task CheckHealthAsync(HealthCheckContext context
new Uri(_documentDbOptions.UriEndpoint),
_documentDbOptions.PrimaryKey))
{
- await documentDbClient.OpenAsync();
+ await documentDbClient.OpenAsync(cancellationToken);
return HealthCheckResult.Healthy();
}
}
diff --git a/src/HealthChecks.DynamoDb/DynamoDbHealthCheck.cs b/src/HealthChecks.DynamoDb/DynamoDbHealthCheck.cs
index 4dd9f1f2b6..2a98676184 100644
--- a/src/HealthChecks.DynamoDb/DynamoDbHealthCheck.cs
+++ b/src/HealthChecks.DynamoDb/DynamoDbHealthCheck.cs
@@ -13,11 +13,10 @@ public class DynamoDbHealthCheck
private readonly DynamoDBOptions _options;
public DynamoDbHealthCheck(DynamoDBOptions options)
{
+ _options = options ?? throw new ArgumentNullException(nameof(options));
if (string.IsNullOrEmpty(options.AccessKey)) throw new ArgumentNullException(nameof(DynamoDBOptions.AccessKey));
if (string.IsNullOrEmpty(options.SecretKey)) throw new ArgumentNullException(nameof(DynamoDBOptions.SecretKey));
if (options.RegionEndpoint == null) throw new ArgumentNullException(nameof(DynamoDBOptions.RegionEndpoint));
-
- _options = options;
}
public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
@@ -26,7 +25,7 @@ public async Task CheckHealthAsync(HealthCheckContext context
var credentials = new BasicAWSCredentials(_options.AccessKey, _options.SecretKey);
var client = new AmazonDynamoDBClient(credentials, _options.RegionEndpoint);
- await client.ListTablesAsync();
+ await client.ListTablesAsync(cancellationToken);
return HealthCheckResult.Healthy();
}
catch (Exception ex)
diff --git a/src/HealthChecks.Elasticsearch/DependencyInjection/ElasticsearchHealthCheckBuilderExtensions.cs b/src/HealthChecks.Elasticsearch/DependencyInjection/ElasticsearchHealthCheckBuilderExtensions.cs
index d5be82ec62..c70fd45e75 100644
--- a/src/HealthChecks.Elasticsearch/DependencyInjection/ElasticsearchHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.Elasticsearch/DependencyInjection/ElasticsearchHealthCheckBuilderExtensions.cs
@@ -8,13 +8,12 @@ namespace Microsoft.Extensions.DependencyInjection
public static class ElasticsearchHealthCheckBuilderExtensions
{
const string NAME = "elasticsearch";
-
///
/// Add a health check for Elasticsearch databases.
///
/// The .
- /// The Elasticsearchv connection string to be used.
- /// The health check name. Optional. If null the type name 'mongodb' will be used for the name.
+ /// The Elasticsearch connection string to be used.
+ /// The health check name. Optional. If null the type name 'elasticsearch' will be used for the name.
///
/// The that should be reported when the health check fails. Optional. If null then
/// the default status of will be reported.
@@ -32,13 +31,12 @@ public static IHealthChecksBuilder AddElasticsearch(this IHealthChecksBuilder bu
failureStatus,
tags));
}
-
///
/// Add a health check for Elasticsearch databases.
///
/// The .
/// The Elasticsearch option setup.
- /// The health check name. Optional. If null the type name 'mongodb' will be used for the name.
+ /// The health check name. Optional. If null the type name 'elasticsearch' will be used for the name.
///
/// The that should be reported when the health check fails. Optional. If null then
/// the default status of will be reported.
diff --git a/src/HealthChecks.Elasticsearch/ElasticsearchHealthCheck.cs b/src/HealthChecks.Elasticsearch/ElasticsearchHealthCheck.cs
index ae44d7c09a..a4406cc8a3 100644
--- a/src/HealthChecks.Elasticsearch/ElasticsearchHealthCheck.cs
+++ b/src/HealthChecks.Elasticsearch/ElasticsearchHealthCheck.cs
@@ -30,15 +30,12 @@ public async Task CheckHealthAsync(HealthCheckContext context
}
var lowlevelClient = new ElasticClient(settings);
-
var pingResult = await lowlevelClient.PingAsync(cancellationToken: cancellationToken);
-
var isSuccess = pingResult.ApiCall.HttpStatusCode == 200;
return isSuccess
? HealthCheckResult.Healthy()
: new HealthCheckResult(context.Registration.FailureStatus);
-
}
catch (Exception ex)
{
diff --git a/src/HealthChecks.Elasticsearch/ElasticsearchOptions.cs b/src/HealthChecks.Elasticsearch/ElasticsearchOptions.cs
index a09bf3786d..c9734c9545 100644
--- a/src/HealthChecks.Elasticsearch/ElasticsearchOptions.cs
+++ b/src/HealthChecks.Elasticsearch/ElasticsearchOptions.cs
@@ -11,7 +11,6 @@ public class ElasticsearchOptions
public X509Certificate Certificate { get; private set; }
public bool AuthenticateWithBasicCredentials { get; private set; } = false;
public bool AuthenticateWithCertificate { get; private set; } = false;
-
public ElasticsearchOptions UseBasicAuthentication(string name, string password)
{
UserName = name ?? throw new ArgumentNullException(nameof(name));
@@ -22,11 +21,10 @@ public ElasticsearchOptions UseBasicAuthentication(string name, string password)
AuthenticateWithBasicCredentials = true;
return this;
}
-
public ElasticsearchOptions UseCertificate(X509Certificate certificate)
{
Certificate = certificate ?? throw new ArgumentNullException(nameof(certificate));
-
+
UserName = string.Empty;
Password = string.Empty;
AuthenticateWithBasicCredentials = false;
diff --git a/src/HealthChecks.EventStore/DependencyInjection/EventStoreHealthCheckBuilderExtensions.cs b/src/HealthChecks.EventStore/DependencyInjection/EventStoreHealthCheckBuilderExtensions.cs
index 9cbc86abf5..06f5f6bd62 100644
--- a/src/HealthChecks.EventStore/DependencyInjection/EventStoreHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.EventStore/DependencyInjection/EventStoreHealthCheckBuilderExtensions.cs
@@ -7,14 +7,13 @@ namespace Microsoft.Extensions.DependencyInjection
public static class EventStoreHealthCheckBuilderExtensions
{
const string NAME = "eventstore";
-
///
/// Add a health check for EventStore services.
///
/// The .
/// The EventStore connection string to be used.
- /// The EventStore user login. Optional. If null the healthcheck will be processed without authentification.
- /// The EventStore user password. Optional. If null the healthcheck will be processed without authentification.
+ /// The EventStore user login. Optional. If null the healthcheck will be processed without authentication.
+ /// The EventStore user password. Optional. If null the healthcheck will be processed without authentication.
/// The health check name. Optional. If null the type name 'eventstore' will be used for the name.
///
/// The that should be reported when the health check fails. Optional. If null then
diff --git a/src/HealthChecks.EventStore/EventStoreHealthCheck.cs b/src/HealthChecks.EventStore/EventStoreHealthCheck.cs
index ddcb0923bb..96e6a1db74 100644
--- a/src/HealthChecks.EventStore/EventStoreHealthCheck.cs
+++ b/src/HealthChecks.EventStore/EventStoreHealthCheck.cs
@@ -11,11 +11,9 @@ public class EventStoreHealthCheck
: IHealthCheck
{
const string CONNECTION_NAME = "AspNetCore HealthCheck Connection";
-
private readonly string _eventStoreConnection;
private readonly string _login;
private readonly string _password;
-
public EventStoreHealthCheck(string eventStoreConnection, string login, string password)
{
_eventStoreConnection = eventStoreConnection ?? throw new ArgumentNullException(nameof(eventStoreConnection));
diff --git a/src/HealthChecks.Hangfire/DependencyInjection/HangfireHealthCheckBuilderExtensions.cs b/src/HealthChecks.Hangfire/DependencyInjection/HangfireHealthCheckBuilderExtensions.cs
index 4182369d04..d0a358afda 100644
--- a/src/HealthChecks.Hangfire/DependencyInjection/HangfireHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.Hangfire/DependencyInjection/HangfireHealthCheckBuilderExtensions.cs
@@ -8,7 +8,6 @@ namespace Microsoft.Extensions.DependencyInjection
public static class HangfireHealthCheckBuilderExtensions
{
const string NAME = "hangfire";
-
///
/// Add a health check for Hangfire.
///
diff --git a/src/HealthChecks.Hangfire/HangfireHealthCheck.cs b/src/HealthChecks.Hangfire/HangfireHealthCheck.cs
index 17f9edd3bd..2a330ae131 100644
--- a/src/HealthChecks.Hangfire/HangfireHealthCheck.cs
+++ b/src/HealthChecks.Hangfire/HangfireHealthCheck.cs
@@ -10,10 +10,10 @@ namespace HealthChecks.Hangfire
public class HangfireHealthCheck
: IHealthCheck
{
- private readonly HangfireOptions _hangfireOptions = new HangfireOptions();
+ private readonly HangfireOptions _hangfireOptions;
public HangfireHealthCheck(HangfireOptions hangfireOptions)
{
- _hangfireOptions = hangfireOptions;
+ _hangfireOptions = hangfireOptions ?? throw new ArgumentNullException(nameof(hangfireOptions));
}
public Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
@@ -44,7 +44,7 @@ public Task CheckHealthAsync(HealthCheckContext context, Canc
{
return Task.FromResult(new HealthCheckResult(context.Registration.FailureStatus, description: string.Join(" + ", errorList)));
}
-
+
return Task.FromResult(HealthCheckResult.Healthy());
}
catch (Exception ex)
diff --git a/src/HealthChecks.IdSvr/DependencyInjection/IdSvrHealthCheckBuilderExtensions.cs b/src/HealthChecks.IdSvr/DependencyInjection/IdSvrHealthCheckBuilderExtensions.cs
index c6e345adbc..56659596e9 100644
--- a/src/HealthChecks.IdSvr/DependencyInjection/IdSvrHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.IdSvr/DependencyInjection/IdSvrHealthCheckBuilderExtensions.cs
@@ -9,7 +9,6 @@ namespace Microsoft.Extensions.DependencyInjection
public static class IdSvrHealthCheckBuilderExtensions
{
const string NAME = "idsvr";
-
///
/// Add a health check for Identity Server.
///
@@ -24,10 +23,10 @@ public static class IdSvrHealthCheckBuilderExtensions
/// The .
public static IHealthChecksBuilder AddIdentityServer(this IHealthChecksBuilder builder, Uri idSvrUri, string name = default, HealthStatus? failureStatus = default, IEnumerable tags = default)
{
- var registrationName = name ?? NAME;
-
- builder.Services.AddHttpClient(registrationName, client => client.BaseAddress = idSvrUri);
-
+ var registrationName = name ?? NAME;
+
+ builder.Services.AddHttpClient(registrationName, client => client.BaseAddress = idSvrUri);
+
return builder.Add(new HealthCheckRegistration(
registrationName,
sp => new IdSvrHealthCheck(() => sp.GetRequiredService().CreateClient(registrationName)),
diff --git a/src/HealthChecks.IdSvr/IdSvrHealthCheck.cs b/src/HealthChecks.IdSvr/IdSvrHealthCheck.cs
index db91a86ca0..8f1e4d5d05 100644
--- a/src/HealthChecks.IdSvr/IdSvrHealthCheck.cs
+++ b/src/HealthChecks.IdSvr/IdSvrHealthCheck.cs
@@ -25,7 +25,7 @@ public async Task CheckHealthAsync(HealthCheckContext context
if (!response.IsSuccessStatusCode)
{
- return new HealthCheckResult(context.Registration.FailureStatus, description: $"Discover endpoint is not responding with 200 OK, the current status is {response.StatusCode} and the content { (await response.Content.ReadAsStringAsync())}");
+ return new HealthCheckResult(context.Registration.FailureStatus, description: $"Discover endpoint is not responding with 200 OK, the current status is {response.StatusCode} and the content { await response.Content.ReadAsStringAsync() }");
}
return HealthCheckResult.Healthy();
diff --git a/src/HealthChecks.Kafka/DependencyInjection/KafkaHealthCheckBuilderExtensions.cs b/src/HealthChecks.Kafka/DependencyInjection/KafkaHealthCheckBuilderExtensions.cs
index 6129161fc9..82d0680be6 100644
--- a/src/HealthChecks.Kafka/DependencyInjection/KafkaHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.Kafka/DependencyInjection/KafkaHealthCheckBuilderExtensions.cs
@@ -1,5 +1,6 @@
using HealthChecks.Kafka;
using Microsoft.Extensions.Diagnostics.HealthChecks;
+using System;
using System.Collections.Generic;
namespace Microsoft.Extensions.DependencyInjection
@@ -7,7 +8,6 @@ namespace Microsoft.Extensions.DependencyInjection
public static class KafkaHealthCheckBuilderExtensions
{
const string NAME = "kafka";
-
///
/// Add a health check for Kafka cluster.
///
@@ -28,5 +28,28 @@ public static IHealthChecksBuilder AddKafka(this IHealthChecksBuilder builder, D
failureStatus,
tags));
}
+ ///
+ /// Add a health check for Kafka cluster.
+ ///
+ /// The .
+ /// The action to configure the kafka connection configuration parameters to be used.
+ /// The health check name. Optional. If null the type name 'kafka' will be used for the name.
+ ///
+ /// The that should be reported when the health check fails. Optional. If null then
+ /// the default status of will be reported.
+ ///
+ /// A list of tags that can be used to filter sets of health checks. Optional.
+ /// The .
+ public static IHealthChecksBuilder AddKafka(this IHealthChecksBuilder builder, Action> setup, string name = default, HealthStatus? failureStatus = default, IEnumerable tags = default)
+ {
+ var config = new Dictionary();
+ setup?.Invoke(config);
+
+ return builder.Add(new HealthCheckRegistration(
+ name ?? NAME,
+ sp => new KafkaHealthCheck(config),
+ failureStatus,
+ tags));
+ }
}
}
diff --git a/src/HealthChecks.Kafka/KafkaHealthCheck.cs b/src/HealthChecks.Kafka/KafkaHealthCheck.cs
index 2cd757ea23..d9d0c73b26 100644
--- a/src/HealthChecks.Kafka/KafkaHealthCheck.cs
+++ b/src/HealthChecks.Kafka/KafkaHealthCheck.cs
@@ -23,12 +23,10 @@ public async Task CheckHealthAsync(HealthCheckContext context
using (var producer = new Producer(_configuration, new StringSerializer(Encoding.UTF8), new StringSerializer(Encoding.UTF8)))
{
var result = await producer.ProduceAsync("beatpulse-topic", "beatpulse-key", $"Check Kafka healthy on {DateTime.UtcNow}");
-
if (result.Error.Code != ErrorCode.NoError)
{
return new HealthCheckResult(context.Registration.FailureStatus, description: $"ErrorCode {result.Error.Code} with reason ('{result.Error.Reason}')");
}
-
return HealthCheckResult.Healthy();
}
}
diff --git a/src/HealthChecks.Kubernetes/DependencyInjection/KubernetesHealthCheckBuilderExtensions.cs b/src/HealthChecks.Kubernetes/DependencyInjection/KubernetesHealthCheckBuilderExtensions.cs
index 74b4da9888..8c0ec5c87c 100644
--- a/src/HealthChecks.Kubernetes/DependencyInjection/KubernetesHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.Kubernetes/DependencyInjection/KubernetesHealthCheckBuilderExtensions.cs
@@ -3,20 +3,18 @@
using System.Collections.Generic;
using HealthChecks.Kubernetes;
using k8s;
-using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection
{
public static class KubernetesHealthCheckBuilderExtensions
{
const string NAME = "k8s";
-
///
/// Add the Kubernetes Health Check
///
/// The .
/// Action to configure Kubernetes cluster and registrations
- /// The health check name. Optional. If null the type name 'kafka' will be used for the name.
+ /// The health check name. Optional. If null the type name 'k8s' will be used for the name.
///
/// The that should be reported when the health check fails. Optional. If null then
/// the default status of will be reported.
@@ -25,7 +23,6 @@ public static class KubernetesHealthCheckBuilderExtensions
/// The .
public static IHealthChecksBuilder AddKubernetes(this IHealthChecksBuilder builder, Action setup, string name = default, HealthStatus? failureStatus = default, IEnumerable tags = default)
{
-
var kubernetesHealthCheckBuilder = new KubernetesHealthCheckBuilder();
setup?.Invoke(kubernetesHealthCheckBuilder);
diff --git a/src/HealthChecks.Kubernetes/Extensions/KubernetesChecksTaskExtensions.cs b/src/HealthChecks.Kubernetes/Extensions/KubernetesChecksTaskExtensions.cs
index 7993aa307b..7170f99bf5 100644
--- a/src/HealthChecks.Kubernetes/Extensions/KubernetesChecksTaskExtensions.cs
+++ b/src/HealthChecks.Kubernetes/Extensions/KubernetesChecksTaskExtensions.cs
@@ -1,5 +1,4 @@
-
-namespace System.Threading.Tasks
+namespace System.Threading.Tasks
{
public static class KubernetesChecksTaskExtensions
{
diff --git a/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs b/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs
index 36eae7a676..898752a56e 100644
--- a/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs
+++ b/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs
@@ -1,22 +1,18 @@
+using k8s.Models;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using k8s;
-using k8s.Models;
namespace HealthChecks.Kubernetes
{
public class KubernetesChecksExecutor
{
private readonly k8s.Kubernetes _client;
-
- private Dictionary>> _handlers;
-
-
+ private readonly Dictionary>> _handlers;
public KubernetesChecksExecutor(k8s.Kubernetes client)
{
- _client = client;
+ _client = client ?? throw new ArgumentNullException(nameof(client));
_handlers = new Dictionary>>()
{
[typeof(V1Deployment)] = CheckDeploymentAsync,
@@ -24,7 +20,6 @@ public KubernetesChecksExecutor(k8s.Kubernetes client)
[typeof(V1Pod)] = CheckPodAsync
};
}
-
public Task<(bool, string)> CheckAsync(KubernetesResourceCheck resourceCheck, CancellationToken cancellationToken)
{
var handler = _handlers[resourceCheck.ResourceType];
@@ -32,7 +27,6 @@ public KubernetesChecksExecutor(k8s.Kubernetes client)
throw new InvalidOperationException(
$"No handler registered for type {resourceCheck.ResourceType.Name}");
}
-
private async Task<(bool, string)> CheckDeploymentAsync(KubernetesResourceCheck resourceCheck, CancellationToken cancellationToken)
{
var tsc = new TaskCompletionSource<(bool, string)>();
@@ -52,7 +46,6 @@ public KubernetesChecksExecutor(k8s.Kubernetes client)
return await tsc.Task;
}
-
private async Task<(bool, string)> CheckPodAsync(KubernetesResourceCheck resourceCheck, CancellationToken cancellationToken)
{
var tsc = new TaskCompletionSource<(bool, string)>();
@@ -70,9 +63,7 @@ public KubernetesChecksExecutor(k8s.Kubernetes client)
}
return await tsc.Task;
-
}
-
private async Task<(bool, string)> CheckServiceAsync(KubernetesResourceCheck resourceCheck, CancellationToken cancellationToken)
{
var tsc = new TaskCompletionSource<(bool, string)>();
@@ -90,7 +81,6 @@ public KubernetesChecksExecutor(k8s.Kubernetes client)
}
return await tsc.Task;
-
}
}
}
\ No newline at end of file
diff --git a/src/HealthChecks.Kubernetes/KubernetesHealthCheck.cs b/src/HealthChecks.Kubernetes/KubernetesHealthCheck.cs
index 0819144f6f..e21a98862a 100644
--- a/src/HealthChecks.Kubernetes/KubernetesHealthCheck.cs
+++ b/src/HealthChecks.Kubernetes/KubernetesHealthCheck.cs
@@ -3,7 +3,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using k8s.Models;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace HealthChecks.Kubernetes
@@ -12,7 +11,6 @@ public class KubernetesHealthCheck : IHealthCheck
{
private readonly KubernetesHealthCheckBuilder _builder;
private readonly KubernetesChecksExecutor _kubernetesChecksExecutor;
-
public KubernetesHealthCheck(KubernetesHealthCheckBuilder builder,
KubernetesChecksExecutor kubernetesChecksExecutor)
{
@@ -20,7 +18,6 @@ public KubernetesHealthCheck(KubernetesHealthCheckBuilder builder,
_kubernetesChecksExecutor = kubernetesChecksExecutor ??
throw new ArgumentNullException(nameof(kubernetesChecksExecutor));
}
-
public async Task CheckHealthAsync(HealthCheckContext context,
CancellationToken cancellationToken = new CancellationToken())
{
@@ -44,7 +41,7 @@ public async Task CheckHealthAsync(HealthCheckContext context
return HealthCheckResult.Healthy();
}
- catch(AggregateException ex)
+ catch (AggregateException ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, string.Join(",", ex.InnerExceptions.Select(s=> s.Message)));
}
@@ -53,7 +50,5 @@ public async Task CheckHealthAsync(HealthCheckContext context
return new HealthCheckResult(context.Registration.FailureStatus, ex.Message);
}
}
-
-
}
}
\ No newline at end of file
diff --git a/src/HealthChecks.Kubernetes/KubernetesHealthCheckBuilder.cs b/src/HealthChecks.Kubernetes/KubernetesHealthCheckBuilder.cs
index 9962043b4e..6f426d0182 100644
--- a/src/HealthChecks.Kubernetes/KubernetesHealthCheckBuilder.cs
+++ b/src/HealthChecks.Kubernetes/KubernetesHealthCheckBuilder.cs
@@ -6,7 +6,6 @@ public class KubernetesHealthCheckBuilder
{
internal KubernetesClientConfiguration Configuration { get; private set; }
internal KubernetesHealthCheckOptions Options { get; private set; }
-
public KubernetesHealthCheckOptions WithConfiguration(KubernetesClientConfiguration configuration)
{
Configuration = configuration;
diff --git a/src/HealthChecks.Kubernetes/KubernetesHealthCheckOptions.cs b/src/HealthChecks.Kubernetes/KubernetesHealthCheckOptions.cs
index a571742f04..60b7fa0746 100644
--- a/src/HealthChecks.Kubernetes/KubernetesHealthCheckOptions.cs
+++ b/src/HealthChecks.Kubernetes/KubernetesHealthCheckOptions.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Linq;
using k8s;
using k8s.Models;
@@ -11,14 +9,10 @@ public class KubernetesHealthCheckOptions
{
private const string DefaultNamespace = "default";
- internal KubernetesHealthCheckOptions(){}
-
-
+ internal KubernetesHealthCheckOptions() { }
internal List Registrations { get; } = new List();
-
public KubernetesHealthCheckOptions CheckDeployment(string name, Func condition,
string @namespace = DefaultNamespace)
-
{
Func delegateCheck = (o) => condition(o as V1Deployment);
@@ -29,7 +23,6 @@ public KubernetesHealthCheckOptions CheckDeployment(string name, Func condition,
string @namespace = DefaultNamespace)
{
@@ -42,7 +35,6 @@ public KubernetesHealthCheckOptions CheckPod(string name, Func cond
return this;
}
-
public KubernetesHealthCheckOptions CheckService(string name, Func condition,
string @namespace = DefaultNamespace)
{
diff --git a/src/HealthChecks.Kubernetes/KubernetesResourceCheck.cs b/src/HealthChecks.Kubernetes/KubernetesResourceCheck.cs
index a342a05dc2..d1480c21b9 100644
--- a/src/HealthChecks.Kubernetes/KubernetesResourceCheck.cs
+++ b/src/HealthChecks.Kubernetes/KubernetesResourceCheck.cs
@@ -1,19 +1,15 @@
-using System;
-using System.Diagnostics;
-using System.Threading.Tasks;
using k8s;
+using System;
namespace HealthChecks.Kubernetes
{
public class KubernetesResourceCheck
{
- private readonly Func _condition;
-
+ private readonly Func _condition;
+
public Type ResourceType { get; }
public string Name { get; }
public string Namespace { get; }
-
-
private KubernetesResourceCheck(Type type, string name, string @namespace, Func condition)
{
_condition = condition;
@@ -21,12 +17,11 @@ private KubernetesResourceCheck(Type type, string name, string @namespace, Func<
Namespace = @namespace ?? throw new ArgumentNullException(nameof(@namespace));
ResourceType = type ?? throw new ArgumentNullException(nameof(type));
}
-
public static KubernetesResourceCheck Create(string name, string @namespace, Func condition)
- where T: IKubernetesObject =>
-
- new KubernetesResourceCheck(typeof(T),name, @namespace, condition);
-
+ where T: IKubernetesObject
+ {
+ return new KubernetesResourceCheck(typeof(T), name, @namespace, condition);
+ }
public bool Check(IKubernetesObject kubernetesObject)
{
return _condition?.Invoke(kubernetesObject) ?? true;
diff --git a/src/HealthChecks.MongoDb/DependencyInjection/MongoDbHealthCheckBuilderExtensions.cs b/src/HealthChecks.MongoDb/DependencyInjection/MongoDbHealthCheckBuilderExtensions.cs
index b8c1861a75..012ae31b85 100644
--- a/src/HealthChecks.MongoDb/DependencyInjection/MongoDbHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.MongoDb/DependencyInjection/MongoDbHealthCheckBuilderExtensions.cs
@@ -1,14 +1,13 @@
using HealthChecks.MongoDb;
using Microsoft.Extensions.Diagnostics.HealthChecks;
-using System.Collections.Generic;
using MongoDB.Driver;
+using System.Collections.Generic;
namespace Microsoft.Extensions.DependencyInjection
{
public static class MongoDbHealthCheckBuilderExtensions
{
const string NAME = "mongodb";
-
///
/// Add a health check for MongoDb database that list all databases on the system.
///
@@ -29,7 +28,6 @@ public static IHealthChecksBuilder AddMongoDb(this IHealthChecksBuilder builder,
failureStatus,
tags));
}
-
///
/// Add a health check for MongoDb database that list all collections from specified database on .
///
@@ -51,7 +49,6 @@ public static IHealthChecksBuilder AddMongoDb(this IHealthChecksBuilder builder,
failureStatus,
tags));
}
-
///
/// Add a health check for MongoDb database that list all collections from specified database on .
///
@@ -72,7 +69,6 @@ public static IHealthChecksBuilder AddMongoDb(this IHealthChecksBuilder builder,
failureStatus,
tags));
}
-
///
/// Add a health check for MongoDb database that list all collections from specified database on .
///
diff --git a/src/HealthChecks.MongoDb/HealthChecks.MongoDb.csproj b/src/HealthChecks.MongoDb/HealthChecks.MongoDb.csproj
index 1c203637df..ae664cc55a 100644
--- a/src/HealthChecks.MongoDb/HealthChecks.MongoDb.csproj
+++ b/src/HealthChecks.MongoDb/HealthChecks.MongoDb.csproj
@@ -1,5 +1,4 @@
-
$(NetStandardTargetVersion)$(PackageLicenseUrl)
@@ -23,6 +22,4 @@
runtime; build; native; contentfiles; analyzers
-
-
diff --git a/src/HealthChecks.MongoDb/MongoDbHealthCheck.cs b/src/HealthChecks.MongoDb/MongoDbHealthCheck.cs
index d935246fa1..078b257ed2 100644
--- a/src/HealthChecks.MongoDb/MongoDbHealthCheck.cs
+++ b/src/HealthChecks.MongoDb/MongoDbHealthCheck.cs
@@ -13,7 +13,6 @@ public class MongoDbHealthCheck
private static readonly ConcurrentDictionary _mongoClient = new ConcurrentDictionary();
private readonly MongoClientSettings _mongoClientSettings;
private readonly string _specifiedDatabase;
-
public MongoDbHealthCheck(string connectionString, string databaseName = default)
: this(MongoClientSettings.FromUrl(MongoUrl.Create(connectionString)), databaseName)
{
diff --git a/src/HealthChecks.MySql/DependencyInjection/MySqlHealthCheckBuilderExtensions.cs b/src/HealthChecks.MySql/DependencyInjection/MySqlHealthCheckBuilderExtensions.cs
index 142a3a5074..09e537f959 100644
--- a/src/HealthChecks.MySql/DependencyInjection/MySqlHealthCheckBuilderExtensions.cs
+++ b/src/HealthChecks.MySql/DependencyInjection/MySqlHealthCheckBuilderExtensions.cs
@@ -7,13 +7,12 @@ namespace Microsoft.Extensions.DependencyInjection
public static class MySqlHealthCheckBuilderExtensions
{
const string NAME = "mysql";
-
///
/// Add a health check for MySql databases.
///
/// The .
/// The MySql connection string to be used.
- /// The health check name. Optional. If null the type name 'mongodb' will be used for the name.
+ /// The health check name. Optional. If null the type name 'mysql' will be used for the name.
///
/// The that should be reported when the health check fails. Optional. If null then
/// the default status of will be reported.
diff --git a/src/HealthChecks.Network/Core/MailConnection.cs b/src/HealthChecks.Network/Core/MailConnection.cs
index 6e54fbb705..04f653d307 100644
--- a/src/HealthChecks.Network/Core/MailConnection.cs
+++ b/src/HealthChecks.Network/Core/MailConnection.cs
@@ -15,10 +15,10 @@ public class MailConnection : IDisposable
public string Host { get; protected set; }
protected bool UseSSL { get; set; } = true;
- protected TcpClient _tcpClient = null;
- protected Stream _stream = null;
+ protected TcpClient _tcpClient;
+ protected Stream _stream;
protected Func