CommonHelpers.HealthCheck 0.0.1-beta.1

This is a prerelease version of CommonHelpers.HealthCheck.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package CommonHelpers.HealthCheck --version 0.0.1-beta.1
                    
NuGet\Install-Package CommonHelpers.HealthCheck -Version 0.0.1-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CommonHelpers.HealthCheck" Version="0.0.1-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CommonHelpers.HealthCheck" Version="0.0.1-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="CommonHelpers.HealthCheck" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CommonHelpers.HealthCheck --version 0.0.1-beta.1
                    
#r "nuget: CommonHelpers.HealthCheck, 0.0.1-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CommonHelpers.HealthCheck@0.0.1-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CommonHelpers.HealthCheck&version=0.0.1-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CommonHelpers.HealthCheck&version=0.0.1-beta.1&prerelease
                    
Install as a Cake Tool

🩺 CommonHelpers.HealthCheck

Extensões fluentes para configuração padronizada de Health Checks, probes de Liveness (/liveness), Readiness (/ready) e dashboard com UI (/health) em ASP.NET Core e Worker Services (.NET 8 e .NET 9).

.NET 8.0 .NET 9.0 Version License: MIT


📦 Instalação

Adicione o pacote ao seu projeto via .NET CLI:

dotnet add package CommonHelpers.HealthCheck --version 0.0.1-beta.1

Ou através do Gerenciador de Pacotes do Visual Studio:

Install-Package CommonHelpers.HealthCheck -Version 0.0.1-beta.1

🚀 Como Usar

1. Em Web APIs / Minimal APIs (ASP.NET Core)

Configure os probes padrão no seu Program.cs:

using CommonHelpers.HealthCheck;

var builder = WebApplication.CreateBuilder(args);

// 1. Registra os Health Checks padrão (Liveness e Readiness)
builder.Services.AddRequiredHealthChecks();

var app = builder.Build();

// 2. Mapeia automaticamente as rotas /health, /liveness e /ready
app.MapRequiredHealthCheck();

app.Run();

2. Adicionando Verificações Customizadas (Banco de Dados, Filas, APIs)

builder.Services.AddRequiredHealthChecks(() => new[]
{
    new CheckConfig("database", new[] { "ready" }, () => HealthCheckResult.Healthy(), TimeSpan.FromSeconds(2)),
    new CheckConfig("redis_cache", new[] { "ready" }, () => HealthCheckResult.Healthy(), TimeSpan.FromSeconds(1)),
    new CheckConfig("payment_gateway", new[] { "live" }, () => HealthCheckResult.Healthy(), TimeSpan.FromSeconds(5))
});

3. Em Worker Services (Background Services)

Mesmo em aplicações que rodam apenas em background sem servidor web nativo, você pode acoplar um web host interno para expor os endpoints de diagnóstico para o Kubernetes:

using CommonHelpers.HealthCheck;

IHost host = Host.CreateDefaultBuilder(args)
    .AddWorkerServiceHealthChecks() // Acopla um endpoint web interno para /liveness e /ready
    .ConfigureServices(services =>
    {
        services.AddHostedService<QueueProcessingWorker>();
    })
    .Build();

await host.RunAsync();

4. Customização de Rotas via appsettings.json

Você pode sobrescrever as rotas padrão diretamente no arquivo de configuração:

{
  "HealthCheckConfig": {
    "Timeout": 30,
    "Patterns": {
      "Health": "/custom-health",
      "Liveness": "/custom-liveness",
      "Readiness": "/custom-ready"
    }
  }
}

🏛️ Endpoints Padrão Expostos

  • /health: Resposta detalhada formatada para consumo pelo UI Client.
  • /liveness: Sonda de vivacidade para orquestradores (Kubernetes / Docker).
  • /ready: Sonda de prontidão para recebimento de tráfego.
Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated