Path: redb-route/redb.Route/Extensions/RouteHealthCheck.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Extensions/RouteHealthCheck.cs
----
#pragma warning disable CS0619
using Microsoft.Extensions.Diagnostics.HealthChecks;
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.Extensions;
///
/// Health check that reports per-route status and endpoint health.
/// Aggregates route lifecycle state and endpoint statistics into an overall health result.
///
/// Unhealthy: an Errored route, or a route whose source endpoint is Critical or Failed.
/// Degraded: a stopped or suspended route, a source endpoint with a Warning, or an endpoint the routes send to
/// that is Critical or Failed (a broker that blocks it, a high error rate); those are listed under
/// endpoints by masked URI, at most . URIs in the result never carry secrets.
///
///
public sealed class RouteHealthCheck : IHealthCheck
{
/// How many failing send-side endpoints the result lists; the rest are counted in endpointsNotListed.
public const int MaxListedEndpoints = 10;
private readonly IRouteContext _context;
/// Creates a route context health check.
/// The route context instance.
public RouteHealthCheck(IRouteContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context));
}
///
public Task CheckHealthAsync(
HealthCheckContext context,
CancellationToken cancellationToken = default)
{
var routes = _context.Routes;
if (routes.Count == 0)
{
return Task.FromResult(HealthCheckResult.Degraded(
"No routes are registered."));
}
var overallStatus = HealthStatus.Healthy;
var routeDetails = new List