Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running health checks in Check method #1987

Merged
merged 3 commits into from
Jan 5, 2023

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Dec 12, 2022

Fixes #1963

This has a behavioral change to always run health checks when the Check method is called, and when the Watch method returns its initial results. I think the behavioral change is worth it because it stops the problem of apps calling the method before the health check publisher has published results.

Setting UseHealthChecksCache to true reverts behavior to always using cached health check publisher results.

New API:

namespace Grpc.AspNetCore.HealthChecks;

public sealed class GrpcHealthChecksOptions
{
+    public bool UseHealthChecksCache { get; set; }
}

Usage:

var services = new ServiceCollection();
services
    .AddGrpcHealthChecks(o =>
    {
        o.Services.MapService("", result => !result.Tags.Contains("exclude"));
        o.UseHealthChecksCache = true;
    });

@JamesNK JamesNK merged commit f7e186f into grpc:master Jan 5, 2023
@JamesNK JamesNK deleted the jamesnk/healthchecks-check branch January 5, 2023 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gRPC health checks difficult to use in common scenarios - they always use IHealthCheckPublisher
2 participants