From a83994f94f8dcb649ddb10a158a9d3ddb5b525c3 Mon Sep 17 00:00:00 2001 From: Artem Leshchev Date: Mon, 3 Jun 2024 09:27:58 +0200 Subject: [PATCH] Add possibility to extend ready check --- src/Bss.Platform.Kubernetes/DependencyInjection.cs | 13 +++++++++++++ src/Bss.Platform.Logging/DependencyInjection.cs | 2 +- src/Directory.Packages.props | 2 +- src/__SolutionItems/CommonAssemblyInfo.cs | 6 +++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Bss.Platform.Kubernetes/DependencyInjection.cs b/src/Bss.Platform.Kubernetes/DependencyInjection.cs index 797e5b5..47619b5 100644 --- a/src/Bss.Platform.Kubernetes/DependencyInjection.cs +++ b/src/Bss.Platform.Kubernetes/DependencyInjection.cs @@ -29,4 +29,17 @@ public static IApplicationBuilder UsePlatformKubernetesHealthChecks(this IApplic app .UseHealthChecks("/health/live", new HealthCheckOptions { Predicate = _ => false }) .UseHealthChecks("/health/ready", new HealthCheckOptions { Predicate = x => x.Name == SqlHealthCheck }); + + public static IHealthChecksBuilder AddPlatformKubernetesHealthChecks( + this IServiceCollection services, + string connectionString, + string sqlCheckName) => + services + .AddHealthChecks() + .AddSqlServer(connectionString, name: sqlCheckName); + + public static IApplicationBuilder UsePlatformKubernetesHealthChecks(this IApplicationBuilder app, params string[] readyCheckNames) => + app + .UseHealthChecks("/health/live", new HealthCheckOptions { Predicate = _ => false }) + .UseHealthChecks("/health/ready", new HealthCheckOptions { Predicate = x => readyCheckNames.Contains(x.Name) }); } diff --git a/src/Bss.Platform.Logging/DependencyInjection.cs b/src/Bss.Platform.Logging/DependencyInjection.cs index f0a6db1..445d706 100644 --- a/src/Bss.Platform.Logging/DependencyInjection.cs +++ b/src/Bss.Platform.Logging/DependencyInjection.cs @@ -10,7 +10,7 @@ namespace Bss.Platform.Logging; public static class DependencyInjection { - public static void AddPlatformLogging(this IHostBuilder builder) => + public static IHostBuilder AddPlatformLogging(this IHostBuilder builder) => builder .UseSerilog( (context, services, configuration) => diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 828550c..92cd64c 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -16,7 +16,7 @@ - + diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index 943fdf8..905dd4c 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2024")] -[assembly: AssemblyVersion("1.5.0.0")] -[assembly: AssemblyFileVersion("1.5.0.0")] -[assembly: AssemblyInformationalVersion("1.5.0.0")] +[assembly: AssemblyVersion("1.5.1.0")] +[assembly: AssemblyFileVersion("1.5.1.0")] +[assembly: AssemblyInformationalVersion("1.5.1.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]