Record Class HealthResult
java.lang.Object
java.lang.Record
cloud.opencode.base.observability.health.HealthResult
- Record Components:
name- the health check name | 健康检查名称status- the health status | 健康状态detail- optional detail message (may be null) | 可选的详情消息(可为 null)duration- the time taken to execute the check | 执行检查所花费的时间
public record HealthResult(String name, HealthStatus status, String detail, Duration duration)
extends Record
Immutable result of a single health check execution.
单次健康检查执行的不可变结果。
Contains the check name, status, optional detail message, and the duration
it took to execute. Factory methods up(String, Duration), down(String, String, Duration), and degraded(String, String, Duration)
provide convenient construction for common cases.
包含检查名称、状态、可选的详情消息以及执行耗时。
工厂方法 up(String, Duration)、down(String, String, Duration) 和 degraded(String, String, Duration) 为常见场景提供便捷构造。
- Since:
- JDK 25, opencode-base-observability V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHealthResult(String name, HealthStatus status, String detail, Duration duration) Compact constructor with validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic HealthResultCreates a DEGRADED result with a detail message.detail()Returns the value of thedetailrecord component.static HealthResultCreates a DOWN result with a detail message.duration()Returns the value of thedurationrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.status()Returns the value of thestatusrecord component.final StringtoString()Returns a string representation of this record class.static HealthResultCreates an UP result with no detail.
-
Constructor Details
-
HealthResult
Compact constructor with validation. 带验证的紧凑构造器。- Throws:
ObservabilityException- if name is null/blank, status is null, or duration is null | 如果 name 为 null/空白、status 为 null 或 duration 为 null
-
-
Method Details
-
up
Creates an UP result with no detail. 创建一个无详情的 UP 结果。- Parameters:
name- the health check name | 健康检查名称duration- the time taken | 执行耗时- Returns:
- a new UP health result | 新的 UP 健康结果
-
down
Creates a DOWN result with a detail message. 创建一个带详情消息的 DOWN 结果。- Parameters:
name- the health check name | 健康检查名称detail- the detail message | 详情消息duration- the time taken | 执行耗时- Returns:
- a new DOWN health result | 新的 DOWN 健康结果
-
degraded
Creates a DEGRADED result with a detail message. 创建一个带详情消息的 DEGRADED 结果。- Parameters:
name- the health check name | 健康检查名称detail- the detail message | 详情消息duration- the time taken | 执行耗时- Returns:
- a new DEGRADED health result | 新的 DEGRADED 健康结果
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
-
status
-
detail
-
duration
-