I am using neo4jclient graph database with .net core API. I have to add the health checks. I have created my own health check using Ihealthcheck interface. below is my healthcheck class
public class DatabaseHealthCheck : IHealthCheck
{
public DatabaseHealthCheck(IGraphClient graphClient)
{
_graphClient = graphClient;
}
private readonly IGraphClient _graphClient;
public async Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context,
CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var result = await _graphClient.Cypher.Match(@"show databases")
.Return((n) => n.As<DatabaseDetail>()).ResultsAsync;
foreach (var res in result)
{
if (res.currentStatus == "Online")
{
return await Task.FromResult(
HealthCheckResult.Healthy("Healthy"));
}
}
}
catch (Exception ex)
{
return new HealthCheckResult(status: context.Registration.FailureStatus, exception: ex);
}
return HealthCheckResult.Healthy();
// return await Task.FromResult(
// new HealthCheckResult(context.Registration.FailureStatus,
// "Unhealthy"));
}
}
With this health check I want to get the database details and then check the status of database weather it is online or not but I am getting the below error
Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied.
Can anyone help me ?