Interface HealthCheck

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface HealthCheck
One dependency or condition a probe reports on, such as a database connection or a warm cache. Register it with Health.Builder.liveness(java.lang.String, com.jsgalactic.axiom.observability.HealthCheck) or Health.Builder.readiness(java.lang.String, com.jsgalactic.axiom.observability.HealthCheck).

An implementation must be thread-safe and fast. It runs on its own virtual thread under the probe timeout; when the timeout passes the thread is interrupted and the check counts as unhealthy, so a check should honor interruption. A check that is still running from an earlier probe is not started again: it is reported unhealthy until it returns. Returning false, throwing and timing out all mean unhealthy; the reason is logged but never sent to the prober.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Evaluates the condition.
  • Method Details

    • isHealthy

      boolean isHealthy() throws Exception
      Evaluates the condition.
      Returns:
      true when healthy
      Throws:
      Exception - if the condition cannot be determined, which counts as unhealthy