HealthCheckPlus.Abstractions 4.0.0

dotnet add package HealthCheckPlus.Abstractions --version 4.0.0
                    
NuGet\Install-Package HealthCheckPlus.Abstractions -Version 4.0.0
                    
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="HealthCheckPlus.Abstractions" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HealthCheckPlus.Abstractions" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="HealthCheckPlus.Abstractions" />
                    
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 HealthCheckPlus.Abstractions --version 4.0.0
                    
#r "nuget: HealthCheckPlus.Abstractions, 4.0.0"
                    
#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 HealthCheckPlus.Abstractions@4.0.0
                    
#: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=HealthCheckPlus.Abstractions&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=HealthCheckPlus.Abstractions&version=4.0.0
                    
Install as a Cake Tool

HealthCheckPlus Logo HealthCheckPlus.Abstractions

Abstractions of HealthCheckPlus - the shared contract between the main package and your own code.

Build License NuGet Downloads

This package holds only the types you need to read HealthCheckPlus state and write your own IHealthCheckPublisher - without depending on ASP.NET Core or the main HealthCheckPlus package's registration/middleware surface. Reach for it from a class library, a background worker, or any project that consumes health state but doesn't itself register or serve health checks.

If you're looking for AddHealthChecksPlus, UseHealthChecksPlus, AddBackgroundPolicy, or the response-writer templates, those live in the main HealthCheckPlus package instead - installing it already brings this one in as a dependency.

Table of Contents

Installing

Top

Install-Package HealthCheckPlus.Abstractions [-pre]
dotnet add package HealthCheckPlus.Abstractions [--prerelease]

Note: [-pre]/[--prerelease] usage for pre-release versions

What's in this package

Top

  • IStateHealthChecksPlus - read cached check results and named aggregates (Status, StatusResult, TryGetHealthy/TryGetNotHealthy/TryGetDegraded/TryGetUnhealthy, ConvertToPlus), or force a manual override (SwitchToUnhealthy/SwitchToDegraded). Resolve it from DI in any project that also references the main HealthCheckPlus package, which registers the implementation.
  • IDataHealthPlus - one check's last result (Name, LastResult, Duration, DateRef, Origin), the shape ConvertToPlus returns.
  • HealthCheckTrigger - what triggered a result (UrlRequest, Background, SwitchTo, None, Default).
  • IHealthCheckPlusPublisher - implement this (instead of the native IHealthCheckPublisher) to add an optional PublisherCondition the background service checks before invoking your publisher.
  • HealthReportExtensions - convenience extensions on the native HealthReport (StatusResult, TryGetHealthy/TryGetNotHealthy/TryGetDegraded/TryGetUnhealthy) for code that only ever sees a plain HealthReport (e.g. inside an IHealthCheckPublisher), without needing IStateHealthChecksPlus at all.

Usage

Top

Reading state from anywhere IStateHealthChecksPlus can be resolved (requires the main HealthCheckPlus package to be registered somewhere in the same host):

public class SomeService(IStateHealthChecksPlus state)
{
    public void Report()
    {
        var overall = state.Status();               // default aggregate
        var redis = state.StatusResult("MyRedis");   // one check's last HealthCheckResult

        if (state.TryGetUnhealthy(out var unhealthy))
        {
            foreach (var (name, result) in unhealthy)
            {
                // ...
            }
        }
    }
}

Writing a publisher with its own opt-in condition:

public class MyPublisher : IHealthCheckPlusPublisher
{
    public Func<HealthReport, bool>? PublisherCondition { get; set; } = report => report.Status != HealthStatus.Healthy;

    public Task PublishAsync(HealthReport report, CancellationToken cancellationToken)
    {
        if (report.TryGetUnhealthy(out var unhealthy))
        {
            // ...
        }
        return Task.CompletedTask;
    }
}

Documentation

Top

  • Points of attention - what to know before you build on HealthCheckPlus, in plain language. Start here.
  • Architecture - how HealthCheckPlus is put together internally, for maintainers and contributors.
  • Operational runbook - how to read a health check response and diagnose common problems, for operators.
  • API reference - generated from the XML doc comments.

Changelog

Top

See CHANGELOG.md for the version history (shared with the main package - both are versioned and released together).

Code of Conduct

Top

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the Code of Conduct.

Contributing

Top

See the Contributing guide for developer documentation.

License

Top

Copyright 2023 @ Fernando Cerqueira

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on HealthCheckPlus.Abstractions:

Package Downloads
HealthCheckPlus

HealthCheck with individual policies based on healthy/degraded/unhealthy status and optimized Report Publisher.

GitHub repositories

This package is not used by any popular GitHub repositories.