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 HealthStatus
DOWN
Indicates the service is down and unavailable.static java.lang.String
NAME_DOWN
The default name to use for anDOWN
status.static java.lang.String
NAME_UP
The default name to use for anUP
status.static HealthStatus
UNKNOWN
Indicates the service status is unknown.static HealthStatus
UP
Indicates 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 int
compareTo(HealthStatus o)
Sorts statuses in order of "functioning level".HealthStatus
describe(java.lang.String description)
Describe an existingHealthStatus
.boolean
equals(java.lang.Object o)
java.util.Optional<java.lang.String>
getDescription()
java.lang.String
getName()
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.int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
NAME_UP
public static final java.lang.String NAME_UP
The default name to use for anUP
status.- See Also:
- Constant Field Values
-
NAME_DOWN
public static final java.lang.String NAME_DOWN
The default name to use for anDOWN
status.- 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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:
compareTo
in interfacejava.lang.Comparable<HealthStatus>
- Parameters:
o
- The status to compare- Returns:
- -1, 1, or 0
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-