DotNetDiag.HealthChecks.MongoDb
10.0.16
dotnet add package DotNetDiag.HealthChecks.MongoDb --version 10.0.16
NuGet\Install-Package DotNetDiag.HealthChecks.MongoDb -Version 10.0.16
<PackageReference Include="DotNetDiag.HealthChecks.MongoDb" Version="10.0.16" />
<PackageVersion Include="DotNetDiag.HealthChecks.MongoDb" Version="10.0.16" />
<PackageReference Include="DotNetDiag.HealthChecks.MongoDb" />
paket add DotNetDiag.HealthChecks.MongoDb --version 10.0.16
#r "nuget: DotNetDiag.HealthChecks.MongoDb, 10.0.16"
#:package DotNetDiag.HealthChecks.MongoDb@10.0.16
#addin nuget:?package=DotNetDiag.HealthChecks.MongoDb&version=10.0.16
#tool nuget:?package=DotNetDiag.HealthChecks.MongoDb&version=10.0.16
MongoDB Health Check
This health check verifies the ability to communicate with MongoDB. It uses the provided MongoClient to list database names or ping configured database.
Defaults
By default, the MongoClient instance is resolved from service provider.
void Configure(IHealthChecksBuilder builder)
{
builder.Services
.AddSingleton(sp => new MongoClient("mongodb://localhost:27017"))
.AddHealthChecks()
.AddMongoDb();
}
Customization
You can additionally add the following parameters:
clientFactory: A factory method to provideMongoClientinstance.databaseNameFactory: A factory method to provide database name.name: The health check name. The default ismongodb.failureStatus: TheHealthStatusthat should be reported when the health check fails. Default isHealthStatus.Unhealthy.tags: A list of tags that can be used to filter sets of health checks.timeout: ASystem.TimeSpanrepresenting the timeout of the check.
void Configure(IHealthChecksBuilder builder)
{
builder.Services
.AddSingleton(sp => new MongoClient("mongodb://localhost:27017"))
.AddHealthChecks()
.AddMongoDb(databaseNameFactory: sp => "theName");
}
Breaking changes
MongoDbHealthCheck was letting the users specify how MongoClient should be created (from raw connection string or from MongoUrl or from MongoClientSettings), at a cost of maintaining an internal, static client instances cache. Now the type does not create client instances nor maintain an internal cache and it's the caller responsibility to provide the instance of MongoClient (please see #2048 for more details). Since MongoDB recommends treating clients as singletons and client instances can be expensive to create, it's recommended to register a singleton factory method for MongoClient. So the client is created only when needed and once per whole application lifetime.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.31)
- MongoDB.Driver (>= 3.9.0)
-
net10.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.12)
- MongoDB.Driver (>= 3.9.0)
-
net8.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.31)
- MongoDB.Driver (>= 3.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on DotNetDiag.HealthChecks.MongoDb:
| Repository | Stars |
|---|---|
|
IoTSharp/IoTSharp
IoTSharp is an open-source IoT platform for data collection, processing, visualization, and device management.
|