Class HeartbeatMonitor.Builder
java.lang.Object
cloud.opencode.base.event.monitor.HeartbeatMonitor.Builder
- Enclosing class:
HeartbeatMonitor
Builder for
HeartbeatMonitor.
HeartbeatMonitor 的构建器。- Since:
- JDK 25, opencode-base-event V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build a newHeartbeatMonitorinstance.checkPeriod(Duration checkPeriod) Set the check period (how often missed heartbeats are scanned).Set the callback invoked when a heartbeat is missed.
-
Method Details
-
checkPeriod
Set the check period (how often missed heartbeats are scanned). 设置检查周期(扫描心跳超时的频率)。Default: 60 seconds.
默认值:60秒。
- Parameters:
checkPeriod- the check period / 检查周期- Returns:
- this builder / 当前构建器
-
onMissed
Set the callback invoked when a heartbeat is missed. 设置心跳超时时调用的回调。The callback receives the ID of the item that missed its heartbeat. Exceptions thrown by the callback are silently swallowed to keep the monitor running.
回调接收超时项目的ID。回调抛出的异常将被静默吞掉以保持监控器运行。
- Parameters:
onMissed- the callback / 回调函数- Returns:
- this builder / 当前构建器
-
build
Build a newHeartbeatMonitorinstance. 构建新的HeartbeatMonitor实例。- Returns:
- a new HeartbeatMonitor / 新的 HeartbeatMonitor 实例
-