Class HealthCheck

java.lang.Object
codes.grow.packages.vault.core.HealthCheck

public final class HealthCheck extends Object
Implements the health() contract (SPEC section 2.4): never throws for an unhealthy or unreachable service, only for CancelledException and ConfigException.
  • Method Details

    • check

      public static HealthStatus check(HttpTransport transport, String path)
      Probes an endpoint once (no retries) and maps the outcome to a HealthStatus.
      Parameters:
      transport - transport of the client
      path - health path, e.g. /health
      Returns:
      the status
    • checkAsync

      public static CompletableFuture<HealthStatus> checkAsync(HttpTransport transport, String path)
      Parameters:
      transport - transport of the client
      path - health path
      Returns:
      a future with the status (failed only for cancellation and configuration errors)
    • fromResponse

      public static HealthStatus fromResponse(TransportResponse resp)
      Maps a health response: 2xx is healthy; the word comes from a JSON status field ( ok / unhealthy when absent); other string fields become details.
      Parameters:
      resp - the response
      Returns:
      the status
    • fromError

      public static HealthStatus fromError(VaultException e)
      Maps a transport error to unreachable.
      Parameters:
      e - the error
      Returns:
      an unhealthy status with the redacted reason