public final class Health extends HealthComponent
HealthComponent
so that additional contextual details about the system can be
returned along with the Status
.
Health
instances can be created by using Health.Builder
's fluent API. Typical
usage in a HealthIndicator
would be:
try { // do some test to determine state of component return Health.up().withDetail("version", "1.1.2").build(); } catch (Exception ex) { return Health.down(ex).build(); }
Modifier and Type | Class and Description |
---|---|
static class |
Health.Builder
Builder for creating immutable
Health instances. |
Modifier and Type | Method and Description |
---|---|
static Health.Builder |
down()
Create a new
Health.Builder instance with a Status.DOWN status. |
static Health.Builder |
down(Exception ex)
Create a new
Health.Builder instance with an Status.DOWN status and the
specified exception details. |
boolean |
equals(Object obj) |
Map<String,Object> |
getDetails()
Return the details of the health.
|
Status |
getStatus()
Return the status of the health.
|
int |
hashCode() |
static Health.Builder |
outOfService()
Create a new
Health.Builder instance with an Status.OUT_OF_SERVICE status. |
static Health.Builder |
status(Status status)
Create a new
Health.Builder instance with a specific Status . |
static Health.Builder |
status(String statusCode)
Create a new
Health.Builder instance with a specific status code. |
String |
toString() |
static Health.Builder |
unknown()
Create a new
Health.Builder instance with an Status.UNKNOWN status. |
static Health.Builder |
up()
Create a new
Health.Builder instance with an Status.UP status. |
public Status getStatus()
getStatus
in class HealthComponent
null
)public Map<String,Object> getDetails()
public static Health.Builder unknown()
Health.Builder
instance with an Status.UNKNOWN
status.Health.Builder
instancepublic static Health.Builder up()
Health.Builder
instance with an Status.UP
status.Health.Builder
instancepublic static Health.Builder down(Exception ex)
Health.Builder
instance with an Status.DOWN
status and the
specified exception details.ex
- the exceptionHealth.Builder
instancepublic static Health.Builder down()
Health.Builder
instance with a Status.DOWN
status.Health.Builder
instancepublic static Health.Builder outOfService()
Health.Builder
instance with an Status.OUT_OF_SERVICE
status.Health.Builder
instancepublic static Health.Builder status(String statusCode)
Health.Builder
instance with a specific status code.statusCode
- the status codeHealth.Builder
instancepublic static Health.Builder status(Status status)
Health.Builder
instance with a specific Status
.status
- the statusHealth.Builder
instanceCopyright © 2019 Pivotal Software, Inc.. All rights reserved.