Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 5251ca0

Browse files
committed
Aggiunto pollingInterval (default 5 sec.) ai metodi HealthChecks
1 parent 7bfeef6 commit 5251ca0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/CustomLibrary.EFCore/Extensions/DependencyInjection.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static IServiceCollection AddHealthChecksUISQLite<TDbContext>(this IServi
180180
return services;
181181
}
182182

183-
public static IServiceCollection AddHealthChecksUISQLServer<TDbContext>(this IServiceCollection services, string webAddressTitle, string dbConnectionString) where TDbContext : DbContext
183+
public static IServiceCollection AddHealthChecksUISQLServer<TDbContext>(this IServiceCollection services, string webAddressTitle, string dbConnectionString, int pollingInterval = 5) where TDbContext : DbContext
184184
{
185185
services.AddHealthChecks()
186186
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
@@ -190,12 +190,13 @@ public static IServiceCollection AddHealthChecksUISQLServer<TDbContext>(this ISe
190190
services.AddHealthChecksUI(setupSettings: setup =>
191191
{
192192
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
193+
setup.SetEvaluationTimeInSeconds(pollingInterval);
193194
}).AddInMemoryStorage();
194195

195196
return services;
196197
}
197198

198-
public static IServiceCollection AddHealthChecksUIMySQL<TDbContext>(this IServiceCollection services, string webAddressTitle, string dbConnectionString) where TDbContext : DbContext
199+
public static IServiceCollection AddHealthChecksUIMySQL<TDbContext>(this IServiceCollection services, string webAddressTitle, string dbConnectionString, int pollingInterval = 5) where TDbContext : DbContext
199200
{
200201
services.AddHealthChecks()
201202
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
@@ -205,12 +206,13 @@ public static IServiceCollection AddHealthChecksUIMySQL<TDbContext>(this IServic
205206
services.AddHealthChecksUI(setupSettings: setup =>
206207
{
207208
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
209+
setup.SetEvaluationTimeInSeconds(pollingInterval);
208210
}).AddInMemoryStorage();
209211

210212
return services;
211213
}
212214

213-
public static IServiceCollection AddHealthChecksUIPostgreSQL<TDbContext>(this IServiceCollection services, string webAddressTitle, string dbConnectionString) where TDbContext : DbContext
215+
public static IServiceCollection AddHealthChecksUIPostgreSQL<TDbContext>(this IServiceCollection services, string webAddressTitle, string dbConnectionString, int pollingInterval = 5) where TDbContext : DbContext
214216
{
215217
services.AddHealthChecks()
216218
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
@@ -220,6 +222,7 @@ public static IServiceCollection AddHealthChecksUIPostgreSQL<TDbContext>(this IS
220222
services.AddHealthChecksUI(setupSettings: setup =>
221223
{
222224
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
225+
setup.SetEvaluationTimeInSeconds(pollingInterval);
223226
}).AddInMemoryStorage();
224227

225228
return services;

0 commit comments

Comments
 (0)