public final class Health extends Object
Health contains a Status to express the state of a component or
subsystem and some additional details to carry some contextual information.
Health has a fluent API to make it easy to construct instances. Typical usage
in a HealthIndicator would be:
try {
// do some test to determine state of component
return Health.up("version", "1.1.2");
}
catch (Exception ex) {
return Health.down(ex);
}
| Constructor and Description |
|---|
Health(Status status,
Map<String,?> details)
Create a new
Health instance with the specified status and details. |
| Modifier and Type | Method and Description |
|---|---|
static Health |
down()
Create a new
Health instance with a Status.DOWN status. |
static Health |
down(Exception ex)
Create a new
Health instance with an Status.DOWN status an the
specified exception details. |
boolean |
equals(Object obj) |
Map<String,Object> |
getDetails() |
Status |
getStatus() |
int |
hashCode() |
static Health |
outOfService()
Create a new
Health instance with an Status.OUT_OF_SERVICE status. |
static Health |
status(Status status)
|
static Health |
status(String statusCode)
Create a new
Health instance with a specific status code. |
String |
toString() |
static Health |
unknown()
Create a new
Health instance with an Status.UNKNOWN status. |
static Health |
up()
|
Health |
withDetail(String key,
Object data)
Create a new
Health object from this one, containing an additional detail. |
Health |
withException(Exception ex)
Create a new
Health object from this one, containing an additional
exception detail. |
public Status getStatus()
null)public Map<String,Object> getDetails()
public Health withException(Exception ex)
Health object from this one, containing an additional
exception detail.ex - the exceptionHealth instancepublic Health withDetail(String key, Object data)
Health object from this one, containing an additional detail.key - the detail keydata - the detail dataHealth instancepublic static Health unknown()
Health instance with an Status.UNKNOWN status.Health instancepublic static Health down(Exception ex)
Health instance with an Status.DOWN status an the
specified exception details.ex - the exceptionHealth instancepublic static Health down()
Health instance with a Status.DOWN status.Health instancepublic static Health outOfService()
Health instance with an Status.OUT_OF_SERVICE status.Health instancepublic static Health status(String statusCode)
Health instance with a specific status code.Health instanceCopyright © 2014 Pivotal Software, Inc.. All rights reserved.