-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
31 lines (26 loc) · 1011 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using HealthCheckRepro;
await Host.CreateDefaultBuilder()
.ConfigureLogging(loggerBuilder =>
{
loggerBuilder.AddConsole();
})
.ConfigureServices((hostContext, services) => {
#if false
//This works fine - IHealthCheckPublisher.PublishAsync is called
services.AddHealthChecks();
#else
//This does not work - IHealthCheckPublisher.PublishAsync is NEVER called
services.AddHealthChecks()
.AddCheck("test", () =>HealthCheckResult.Healthy("We're good"));
#endif
services.AddSingleton<IHealthCheckPublisher, SimpleHealthCheckPublisher>();
services.Configure<HealthCheckPublisherOptions>(options =>
{
options.Delay = TimeSpan.FromSeconds(1);
options.Period = TimeSpan.FromSeconds(5);
});
}).RunConsoleAsync();