类 Health
- java.lang.Object
- org.springframework.boot.actuate.health.Health
public final class Health extends Object
Carries information about the health of a component or subsystem.Health
contains aStatus
to express the state of a component or subsystem and some additional details to carry some contextual information.Health
instances can be created by usingHealth.Builder
's fluent API. Typical usage in aHealthIndicator
would be:try { // do some test to determine state of component return new Health.Builder().up().withDetail("version", "1.1.2").build(); } catch (Exception ex) { return new Health.Builder().down(ex).build(); }
- 从以下版本开始:
- 1.1.0
嵌套类概要
嵌套类 修饰符和类型 类 说明 static class
Health.Builder
Builder for creating immutableHealth
instances.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static Health.Builder
down()
Create a newHealth.Builder
instance with aStatus.DOWN
status.static Health.Builder
down(Exception ex)
Create a newHealth.Builder
instance with anStatus.DOWN
status an 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 newHealth.Builder
instance with anStatus.OUT_OF_SERVICE
status.static Health.Builder
status(String statusCode)
Create a newHealth.Builder
instance with a specific status code.static Health.Builder
status(Status status)
Create a newHealth.Builder
instance with a specificStatus
.String
toString()
static Health.Builder
unknown()
Create a newHealth.Builder
instance with anStatus.UNKNOWN
status.static Health.Builder
up()
Create a newHealth.Builder
instance with anStatus.UP
status.
方法详细资料
getDetails
public Map<String,Object> getDetails()
Return the details of the health.- 返回:
- the details (or an empty map)
unknown
public static Health.Builder unknown()
Create a newHealth.Builder
instance with anStatus.UNKNOWN
status.- 返回:
- a new
Health.Builder
instance
up
public static Health.Builder up()
Create a newHealth.Builder
instance with anStatus.UP
status.- 返回:
- a new
Health.Builder
instance
down
public static Health.Builder down(Exception ex)
Create a newHealth.Builder
instance with anStatus.DOWN
status an the specified exception details.- 参数:
ex
- the exception- 返回:
- a new
Health.Builder
instance
down
public static Health.Builder down()
Create a newHealth.Builder
instance with aStatus.DOWN
status.- 返回:
- a new
Health.Builder
instance
outOfService
public static Health.Builder outOfService()
Create a newHealth.Builder
instance with anStatus.OUT_OF_SERVICE
status.- 返回:
- a new
Health.Builder
instance
status
public static Health.Builder status(String statusCode)
Create a newHealth.Builder
instance with a specific status code.- 参数:
statusCode
- the status code- 返回:
- a new
Health.Builder
instance
status
public static Health.Builder status(Status status)
Create a newHealth.Builder
instance with a specificStatus
.- 参数:
status
- the status- 返回:
- a new
Health.Builder
instance