这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
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.
 
 
 
 
 
 

35 lines
1.1 KiB

using LINGYUN.Abp.LocalizationManagement;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.MicroService.LocalizationService;
public class ServiceHealthCheck : IHealthCheck
{
private readonly IServiceScopeFactory _scopeFactory;
public ServiceHealthCheck(IServiceScopeFactory scopeFactory)
{
_scopeFactory = scopeFactory;
}
public async virtual Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
using var scope = _scopeFactory.CreateScope();
var repo = scope.ServiceProvider.GetRequiredService<ITextRepository>();
var _ = await repo.GetCountAsync(cancellationToken);
return HealthCheckResult.Healthy();
}
catch (Exception ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}