Lyo.Health
2.0.0
dotnet add package Lyo.Health --version 2.0.0
NuGet\Install-Package Lyo.Health -Version 2.0.0
<PackageReference Include="Lyo.Health" Version="2.0.0" />
<PackageVersion Include="Lyo.Health" Version="2.0.0" />
<PackageReference Include="Lyo.Health" />
paket add Lyo.Health --version 2.0.0
#r "nuget: Lyo.Health, 2.0.0"
#:package Lyo.Health@2.0.0
#addin nuget:?package=Lyo.Health&version=2.0.0
#tool nuget:?package=Lyo.Health&version=2.0.0
Lyo.Health
Contract for services that report their own health. Implement IHealth. There is no central health service. A check returns HealthResult with status, timings, and optional metadata.
Examples
How to use it
// File storage
var fileStorage = app.Services.GetRequiredService<IFileStorageService>();
var result = await fileStorage.CheckHealthAsync();
// result.IsHealthy, result.Duration, result.Metadata, result.Message
// Cache
var cache = app.Services.GetRequiredService<ICacheService>();
var result = await cache.CheckHealthAsync();
// RabbitMQ
var mq = app.Services.GetRequiredService<IMqService>();
var result = await mq.CheckHealthAsync();
The contract
public interface IHealth
{
string HealthCheckName { get; }
Task<HealthResult> CheckHealthAsync(CancellationToken ct = default);
}
HealthResult
HealthResult.Healthy(sw.Elapsed, message: null, metadata: new Dictionary<string, object?> { ["database"] = "audit" });
HealthResult.Unhealthy(sw.Elapsed, "Database connection failed", metadata: null, exception: ex);
The contract
- Hosts label probe output with
HealthCheckName, a short identifier, for example"filestorage","cache","rabbitmq","audit-postgres","change-tracker-postgres". - The live probe is
CheckHealthAsync. Keep it cheap and short-circuiting, and honor the suppliedCancellationToken.
HealthResult
A probe outcome is an immutable, sealed HealthResult:
| Member | Type | Notes |
|---|---|---|
IsHealthy |
bool |
true when healthy, false when not. |
Duration |
TimeSpan |
Elapsed probe time (usually from Stopwatch). |
CheckedAt |
DateTime |
UTC instant the probe finished (set by the factory helpers). |
Message |
string? |
Optional human-readable summary; filled with the exception message on failure. |
Metadata |
IReadOnlyDictionary<string, object?>? |
Schema, version, connection info, key-id, and similar. |
Exception |
Exception? |
Exception captured when the probe threw. |
Prefer the static factories over constructing the type yourself:
How to use it
Ask the service for health directly. Service interfaces (IFileStorageService, ICacheService, IMqService) extend IHealth. Health comes from the service. No separate registration. Hosts that want an aggregate view typically resolve IEnumerable<IHealth> and fan out CheckHealthAsync in parallel, then publish the resulting HealthResult collection.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Exceptions(direct, lyo)
| 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 was computed. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. 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.0
- Lyo.Exceptions (>= 2.0.0)
-
net10.0
- Lyo.Exceptions (>= 2.0.0)
NuGet packages (19)
Showing the top 5 NuGet packages that depend on Lyo.Health:
| Package | Downloads |
|---|---|
|
Lyo.Cache
Cache service abstractions and local IMemoryCache implementation. |
|
|
Lyo.Postgres
Shared PostgreSQL infrastructure for Lyo libraries: schema-scoped DbContext registration, startup migrations, design-time factory helpers, and connectivity health checks. |
|
|
Lyo.MessageQueue
Message queue service interface and base implementation for asynchronous messaging. |
|
|
Lyo.FileStorage
File storage service interface and base implementation for file operations. |
|
|
Lyo.FileMetadataStore.Postgres
PostgreSQL implementation of the Lyo FileMetadataStore service using Entity Framework Core. |
GitHub repositories
This package is not used by any popular GitHub repositories.