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

public class HttpHealthIndicator extends AsyncHealthIndicator
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.

  • Method Details

    • builder

      public static HttpHealthIndicator.Builder builder()
      Returns a new instance of the Builder.
      Returns:
      a new instance of the Builder
    • standard

      public static HttpHealthIndicator standard(okhttp3.Request request)
      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: AsyncHealthIndicator
      Retrieves 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:
      healthInternal in class AsyncHealthIndicator
      Returns:
      the current Health status