| | | 1 | | using Anichron.Infrastructure.Storage; |
| | | 2 | | using Microsoft.Extensions.Diagnostics.HealthChecks; |
| | | 3 | | |
| | | 4 | | namespace Anichron.API.Infrastructure; |
| | | 5 | | |
| | | 6 | | // Mirrors ProxyStorageHealthCheck for the originals mount. Both exist because the two stores |
| | | 7 | | // fail independently: proxies are local SSD, originals are the NAS. |
| | | 8 | | // |
| | | 9 | | // ⚠️ Degraded, not Unhealthy, when the directory is missing. A vanished NAS mount stops |
| | | 10 | | // on-demand serving of originals, but proxies and every other endpoint keep working — so |
| | | 11 | | // reporting Unhealthy would pull the whole API out of rotation for a partial loss of function. |
| | | 12 | | // A THROWING store is a different condition (unreadable or hung mount rather than absent) |
| | | 13 | | // and does report Unhealthy, carrying the exception for diagnosis. |
| | 4 | 14 | | internal sealed class OriginalsStorageHealthCheck(IOriginalStore store) : IHealthCheck |
| | | 15 | | { |
| | | 16 | | public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = de |
| | 3 | 17 | | { |
| | | 18 | | try |
| | 3 | 19 | | { |
| | 3 | 20 | | return Task.FromResult( |
| | 3 | 21 | | store.RootExists() |
| | 3 | 22 | | ? HealthCheckResult.Healthy("Originals storage directory found.") |
| | 3 | 23 | | : HealthCheckResult.Degraded("Originals storage directory not found.")); |
| | | 24 | | } |
| | 1 | 25 | | catch (Exception ex) |
| | 1 | 26 | | { |
| | 1 | 27 | | return Task.FromResult(HealthCheckResult.Unhealthy("Originals storage check failed.", ex)); |
| | | 28 | | } |
| | 3 | 29 | | } |
| | | 30 | | } |