Go C#

Asp.NET Health Checks

ConfigureServices

public void ConfigureServices(IServiceCollection services)
{
    services.AddHealthChecks().AddCheck<ActorSystemHealthCheck>("actor-system");
    //...

Configure

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {

        //....

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();

            endpoints.MapHealthChecks("/health/live");
        });

Health Check implementation

public class ActorSystemHealthCheck : IHealthCheck
{
    private readonly ActorSystem _system;
    public ActorSystemHealthCheck(ActorSystem system)
    {
        _system = system;
    }
        
    public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken()) =>
        _system.Shutdown.IsCancellationRequested switch
        {
            true => Task.FromResult(HealthCheckResult.Unhealthy()),
            _    => Task.FromResult(HealthCheckResult.Healthy())
        };
}
Icon