Package com.helixframework.api.health
Class HttpHealthIndicator
java.lang.Object
com.helixframework.api.health.AsyncHealthIndicator
com.helixframework.api.health.HttpHealthIndicator
- All Implemented Interfaces:
org.springframework.boot.actuate.health.HealthContributor,org.springframework.boot.actuate.health.HealthIndicator
A HealthIndicator implementation that performs health checks by making HTTP requests.
It extends the AsyncHealthIndicator class, which provides asynchronous health checks.
The HTTP health check is performed by making a request using an OkHttpClient instance. The response is then passed through a user-defined healthCheck function to determine the health status. If the response is successful, the health status is set to UP; otherwise, it is set to DOWN.
The health check is performed periodically based on the specified delay and period. If the number of consecutive failures exceeds the maximum allowed failures, the health status is set to DOWN and the health check is stopped.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe Builder class is a utility class used to create instances of HttpHealthIndicator. -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpHealthIndicator.Builderbuilder()Returns a new instance of the Builder.protected org.springframework.boot.actuate.health.HealthRetrieves the current health status.static HttpHealthIndicatorstandard(okhttp3.Request request) Creates a standard HttpHealthIndicator.Methods inherited from class com.helixframework.api.health.AsyncHealthIndicator
getHealth, health
-
Method Details
-
builder
Returns a new instance of the Builder.- Returns:
- a new instance of the Builder
-
standard
Creates a standard HttpHealthIndicator.- Parameters:
request- the request to be used for making the HTTP health check- Returns:
- a new instance of HttpHealthIndicator
- Throws:
IllegalArgumentException- if the request is null
-
healthInternal
protected org.springframework.boot.actuate.health.Health healthInternal()Description copied from class:AsyncHealthIndicatorRetrieves the current health status. This method is called periodically by the AsyncHealthIndicator class to update the health status. It should be implemented by subclasses to provide the actual health check logic.- Specified by:
healthInternalin classAsyncHealthIndicator- Returns:
- the current Health status
-