prep docs and service updates
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled

This commit is contained in:
master
2025-11-21 06:56:36 +00:00
parent ca35db9ef4
commit d519782a8f
242 changed files with 17293 additions and 13367 deletions

View File

@@ -0,0 +1,49 @@
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Options;
using StellaOps.AirGap.Time.Models;
using StellaOps.AirGap.Time.Services;
namespace StellaOps.AirGap.Time.Health;
public sealed class TimeAnchorHealthCheck : IHealthCheck
{
private readonly TimeStatusService _statusService;
private readonly IOptions<AirGapOptions> _options;
public TimeAnchorHealthCheck(TimeStatusService statusService, IOptions<AirGapOptions> options)
{
_statusService = statusService;
_options = options;
}
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
var opts = _options.Value;
var status = await _statusService.GetStatusAsync(opts.TenantId, DateTimeOffset.UtcNow, cancellationToken);
if (status.Anchor == TimeAnchor.Unknown)
{
return HealthCheckResult.Unhealthy("time-anchor-missing");
}
if (status.Staleness.IsBreach)
{
return HealthCheckResult.Unhealthy("time-anchor-stale");
}
var data = new Dictionary<string, object?>
{
["anchorDigest"] = status.Anchor.TokenDigest,
["ageSeconds"] = status.Staleness.AgeSeconds,
["warningSeconds"] = status.Staleness.WarningSeconds,
["breachSeconds"] = status.Staleness.BreachSeconds
};
if (status.Staleness.IsWarning)
{
return HealthCheckResult.Degraded("time-anchor-warning", data);
}
return HealthCheckResult.Healthy("time-anchor-healthy", data);
}
}