/
afanasevn
/
PdfEncoder
Обзор
Документация
Войти
/
afanasevn
/
PdfEncoder
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/PdfEncoder.Infrastructure/Health/StorageHealthCheck.cs
35 строк
1 KB
IBS\NAfanasev
Add project files.
01 июл 2026, 14:54
01 июл 2026, 14:54
8414644
Код
Авторство
О чём код?
using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Options; using PdfEncoder.Application.Options; namespace PdfEncoder.Infrastructure.Health; /// <summary> /// Проверка доступности каталога локального хранилища PDF. /// </summary> public sealed class StorageHealthCheck(IOptions<StorageOptions> options) : IHealthCheck { /// <inheritdoc /> public Task<HealthCheckResult> CheckHealthAsync( HealthCheckContext context, CancellationToken ct = default) { var rootPath = options.Value.RootPath; try { Directory.CreateDirectory(rootPath); if (!Directory.Exists(rootPath)) { return Task.FromResult(HealthCheckResult.Unhealthy("Storage directory does not exist.")); } return Task.FromResult(HealthCheckResult.Healthy("Storage directory is available.")); } catch (Exception ex) { return Task.FromResult(HealthCheckResult.Unhealthy("Storage check failed.", ex)); } } }