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

HealthCheck not supported async mode [enhancement] #211

Open
deripas opened this issue Sep 30, 2019 · 4 comments
Open

HealthCheck not supported async mode [enhancement] #211

deripas opened this issue Sep 30, 2019 · 4 comments

Comments

@deripas
Copy link

deripas commented Sep 30, 2019

Already using jboss-servlet-api_4. 0 which supports AsyncContext (since 3.0).
I want to be able to implement asynchronous HealthCheck, for example:

public class SimpleHealthCheck  implements HealthCheckAsync {
    @Override
    public CompletionStage<HealthCheckResponse> call() {
        return CompletableFuture.supplyAsync(() -> {
            return HealthCheckResponse.builder().up().name("redis/mongo/eq").build();
        });
    }
}

or RxJava

public class SimpleHealthCheck  implements HealthCheckReactive {
    @Override
    public Single<HealthCheckResponse> call() {
        return Single.fromCallable(() -> {
            return HealthCheckResponse.builder().up().name("redis/mongo/eq").build();
        });
    }
}
@kenfinnigan
Copy link

Can you elaborate on the benefits of supporting asynchronous return types given the health check call doesn't actually happen until someone requests it?

@deripas
Copy link
Author

deripas commented Oct 1, 2019

Many libraries already support the asynchronous api, such as: nosql drivers (mongodb-driver-reactivestreams, Cassandra), Redis client (Lettuce ), etc.

doesn't actually happen until someone requests it

Yes, but this is not a one-time request, but a regular load, especially in the context of microservices.
Microservices are periodically polled Liveness/Readiness probs and at the same time have limited resources (cpu, threads, ...).
I'm a little confused that there are ways to do asynchronous rest-controller, but health-check endpoint only blocking mode.
It forces me to abandon the use of health-api (HealthCheck) and make my own health async rest-controller.

@olotenko
Copy link

olotenko commented Jul 21, 2020

I agree with the need to introduce async/rx API. People will poll other services to determine readiness and or liveness, even if you tell them not to. In the absence of asynchronous API this may consume threads unnecessarily. (Compare to JAX-RS AsyncResponse and support for CompletionStage<Response> as the return type)

@xstefank
Copy link
Member

We took a stance to not introduce new features into the specification which may be still unstable. So we introduced async health checks in the SmallRye Health implementation -> https://github.com/smallrye/smallrye-health/blob/master/implementation/src/main/java/io/smallrye/health/SmallRyeHealthReporter.java#L208 that utilize Mutiny as a reactive framework. We also would like to encourage different implementations to also introduce some form of their async API so we can catch most of the errors before we move the API to the spec which would result in a smaller need for breaking changes in the future.

If you can, please give a try and report any problems/enhancements that you find.

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

No branches or pull requests

4 participants