Package com.tnsai.spi

Record Class Healthcheckable.HealthStatus

java.lang.Object
java.lang.Record
com.tnsai.spi.Healthcheckable.HealthStatus
Record Components:
reachable - true when the service responded successfully within the deadline
errorMessage - human-readable reason the probe failed; empty on success
latency - observed wall-clock latency of the probe
Enclosing interface:
Healthcheckable

public static record Healthcheckable.HealthStatus(boolean reachable, Optional<String> errorMessage, Duration latency) extends Record
Outcome of a reachability probe.
  • Constructor Details

    • HealthStatus

      public HealthStatus(boolean reachable, Optional<String> errorMessage, Duration latency)
      Creates an instance of a HealthStatus record class.
      Parameters:
      reachable - the value for the reachable record component
      errorMessage - the value for the errorMessage record component
      latency - the value for the latency record component
  • Method Details

    • healthy

      public static Healthcheckable.HealthStatus healthy(Duration latency)
      The service answered the probe within the timeout.
    • unreachable

      public static Healthcheckable.HealthStatus unreachable(String message, Duration latency)
      The probe failed (network down, auth rejected, deadline missed, etc.). The message should be safe to log — no credentials, no full stack traces.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • reachable

      public boolean reachable()
      Returns the value of the reachable record component.
      Returns:
      the value of the reachable record component
    • errorMessage

      public Optional<String> errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • latency

      public Duration latency()
      Returns the value of the latency record component.
      Returns:
      the value of the latency record component