feat(health): add custom DB, Qdrant, and Neo4j health check services and secure Qdrant in staging
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Qdrant.Client;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NexusReader.Web.Services;
|
||||
|
||||
public class QdrantHealthCheck : IHealthCheck
|
||||
{
|
||||
private readonly QdrantClient _qdrantClient;
|
||||
|
||||
public QdrantHealthCheck(QdrantClient qdrantClient)
|
||||
{
|
||||
_qdrantClient = qdrantClient;
|
||||
}
|
||||
|
||||
public async Task<HealthCheckResult> CheckHealthAsync(
|
||||
HealthCheckContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Simple check: query collection existence to verify connection is alive
|
||||
_ = await _qdrantClient.CollectionExistsAsync("knowledge_units", cancellationToken);
|
||||
return HealthCheckResult.Healthy("Qdrant database is accessible.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return HealthCheckResult.Unhealthy("Qdrant database health check failed.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user