feat: add healthcheck for main project
This commit is contained in:
@ -7,17 +7,19 @@ namespace Mirea.Api.Endpoint.Configuration.Core.Startup;
|
||||
|
||||
public static class CacheConfiguration
|
||||
{
|
||||
public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration)
|
||||
public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration, IHealthChecksBuilder? healthChecksBuilder = null)
|
||||
{
|
||||
var cache = configuration.Get<GeneralConfig>()?.CacheSettings;
|
||||
if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis)
|
||||
if (cache?.TypeDatabase != CacheSettings.CacheEnum.Redis)
|
||||
return services;
|
||||
|
||||
services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
options.Configuration = cache.ConnectionString;
|
||||
options.InstanceName = "mirea_";
|
||||
});
|
||||
}
|
||||
options.Configuration = cache.ConnectionString;
|
||||
options.InstanceName = "mirea_";
|
||||
});
|
||||
|
||||
healthChecksBuilder?.AddRedis(cache.ConnectionString!, name: "Redis");
|
||||
|
||||
return services;
|
||||
}
|
||||
|
Reference in New Issue
Block a user