Package io.micronaut.health
Class HealthStatus
- java.lang.Object
-
- io.micronaut.health.HealthStatus
-
- All Implemented Interfaces:
java.lang.Comparable<HealthStatus>
@Introspected public class HealthStatus extends java.lang.Object implements java.lang.Comparable<HealthStatus>
The status of a health indicator.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static HealthStatusDOWNIndicates the service is down and unavailable.static java.lang.StringNAME_DOWNThe default name to use for anDOWNstatus.static java.lang.StringNAME_UPThe default name to use for anUPstatus.static HealthStatusUNKNOWNIndicates the service status is unknown.static HealthStatusUPIndicates the service is operational.
-
Constructor Summary
Constructors Constructor Description HealthStatus(@NotNull java.lang.String name)HealthStatus(java.lang.String name, java.lang.String description, java.lang.Boolean operational, java.lang.Integer severity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(HealthStatus o)Sorts statuses in order of "functioning level".HealthStatusdescribe(java.lang.String description)Describe an existingHealthStatus.booleanequals(java.lang.Object o)java.util.Optional<java.lang.String>getDescription()java.lang.StringgetName()java.util.Optional<java.lang.Boolean>getOperational()Whether the status represents a functioning service.java.util.Optional<java.lang.Integer>getSeverity()The severity of the status.inthashCode()java.lang.StringtoString()
-
-
-
Field Detail
-
NAME_UP
public static final java.lang.String NAME_UP
The default name to use for anUPstatus.- See Also:
- Constant Field Values
-
NAME_DOWN
public static final java.lang.String NAME_DOWN
The default name to use for anDOWNstatus.- See Also:
- Constant Field Values
-
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 Detail
-
HealthStatus
public HealthStatus(java.lang.String name, java.lang.String description, java.lang.Boolean operational, java.lang.Integer severity)- Parameters:
name- The name of the statusdescription- The detailed information about the statusoperational- If it's operationalseverity- The severity, the higher the value, the more sever is situation.
-
HealthStatus
public HealthStatus(@NotNull @NotNull java.lang.String name)- Parameters:
name- The name of the status
-
-
Method Detail
-
describe
public HealthStatus describe(java.lang.String description)
Describe an existingHealthStatus.- Parameters:
description- The description- Returns:
- The new health status
-
getName
public java.lang.String getName()
- Returns:
- The name of the status
-
getDescription
public java.util.Optional<java.lang.String> getDescription()
- Returns:
- The description of the status
-
getOperational
public java.util.Optional<java.lang.Boolean> getOperational()
Whether the status represents a functioning service.- Returns:
- Empty if partially operational.
-
getSeverity
public java.util.Optional<java.lang.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(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.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:
compareToin interfacejava.lang.Comparable<HealthStatus>- Parameters:
o- The status to compare- Returns:
- -1, 1, or 0
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-