Class HealthStatus

java.lang.Object
io.micronaut.health.HealthStatus
All Implemented Interfaces:
Comparable<HealthStatus>

@Introspected public class HealthStatus extends Object implements Comparable<HealthStatus>

The status of a health indicator.

Since:
1.0
Author:
James Kleeh, Graeme Rocher
  • Field Details

    • NAME_UP

      public static final String NAME_UP
      The default name to use for an UP status.
      See Also:
    • NAME_DOWN

      public static final String NAME_DOWN
      The default name to use for an DOWN status.
      See Also:
    • UP

      public static final HealthStatus UP
      Indicates the service is operational.
    • DOWN

      public static final HealthStatus DOWN
      Indicates the service is down and unavailable.
    • UNKNOWN

      public static final HealthStatus UNKNOWN
      Indicates the service status is unknown.
  • Constructor Details

    • HealthStatus

      public HealthStatus(String name, String description, Boolean operational, Integer severity)
      Parameters:
      name - The name of the status
      description - The detailed information about the status
      operational - If it's operational
      severity - The severity, the higher the value, the more sever is situation.
    • HealthStatus

      public HealthStatus(@NotNull @NotNull String name)
      Parameters:
      name - The name of the status
  • Method Details

    • describe

      public HealthStatus describe(String description)
      Describe an existing HealthStatus.
      Parameters:
      description - The description
      Returns:
      The new health status
    • getName

      public String getName()
      Returns:
      The name of the status
    • getDescription

      public Optional<String> getDescription()
      Returns:
      The description of the status
    • getOperational

      public Optional<Boolean> getOperational()
      Whether the status represents a functioning service.
      Returns:
      Empty if partially operational.
    • getSeverity

      public Optional<Integer> getSeverity()
      The severity of the status. A higher severity indicates a more severe error.
      Returns:
      Empty if no severity specified.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(HealthStatus o)
      Sorts statuses in order of "functioning level". The most functional will appear first and the least functional will appear last.

      Operation is sorted (true, null, false). For statuses with matching operations, severity is sorted ascending, with nulls first.

      Specified by:
      compareTo in interface Comparable<HealthStatus>
      Parameters:
      o - The status to compare
      Returns:
      -1, 1, or 0
    • toString

      public String toString()
      Overrides:
      toString in class Object