public class DefaultHealthCheckService extends Object implements HealthCheckService
HealthCheckService
.
It loads all available HealthCheckService
s from the OSGi service registry.
If no checks are available, the overall health is "Unhealthy".Constructor and Description |
---|
DefaultHealthCheckService(org.osgi.framework.BundleContext bundleContext) |
Modifier and Type | Method and Description |
---|---|
protected List<HealthCheck> |
getHealthChecks() |
CompletableFuture<Health> |
performAsyncHealthCheck(Context context,
java.util.function.Consumer<HealthCheck> onStartConsumer,
java.util.function.Consumer<Response> onFinishConsumer)
Performs various
HealthCheck s asynchronously and returns a CompletableFuture which
contains the Health representing each HealthCheck s Response . |
public DefaultHealthCheckService(org.osgi.framework.BundleContext bundleContext)
protected List<HealthCheck> getHealthChecks() throws org.osgi.framework.InvalidSyntaxException
org.osgi.framework.InvalidSyntaxException
public CompletableFuture<Health> performAsyncHealthCheck(Context context, java.util.function.Consumer<HealthCheck> onStartConsumer, java.util.function.Consumer<Response> onFinishConsumer)
HealthCheckService
HealthCheck
s asynchronously and returns a CompletableFuture
which
contains the Health
representing each HealthCheck
s Response
.
It is up to the implementator to respect timeouts and handle exceptions accordingly, when
these situations arise when calling HealthCheck.perform(Context)
.
Callback methods can be provided to print information before and after a HealthCheck
is invoked.
When providing a onFinishConsumer
please note, that this is
invoked even if the HealthCheck.perform(Context)
execution failed or timed out and therefore may not
represent the value when calling HealthCheck.perform(Context)
directly.performAsyncHealthCheck
in interface HealthCheckService
context
- The context objectonStartConsumer
- Callback method which is invoked before the HealthCheck.perform(Context)
method is invoked. May be null.onFinishConsumer
- Callback method which is invoked after the HealthCheck.perform(Context)
method is invoked. May be null.CompletableFuture
to retrieve the Health
from.Copyright © 2020. All rights reserved.