mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.2 KiB
31 lines
1.2 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using EventStore.Client;
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
|
|
namespace Squidex.Infrastructure.Diagnostics
|
|
{
|
|
public sealed class GetEventStoreHealthCheck : IHealthCheck
|
|
{
|
|
private readonly EventStoreClient client;
|
|
|
|
public GetEventStoreHealthCheck(EventStoreClientSettings settings)
|
|
{
|
|
client = new EventStoreClient(settings);
|
|
}
|
|
|
|
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
await client.ReadStreamAsync(Direction.Forwards, "test", default, cancellationToken: cancellationToken)
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
return HealthCheckResult.Healthy("Application must query data from EventStore.");
|
|
}
|
|
}
|
|
}
|
|
|