Documentation
¶
Overview ¶
Package heartbeat 实现定期心跳服务,用于监控系统状态并向用户发送活跃提醒。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool // 是否启用心跳
Interval time.Duration // 心跳探测间隔
MaxIdle time.Duration // 会话最大允许空闲时间(超过后停止发送心跳)
}
Config 控制心跳服务的运行时行为。
type DispatchFunc ¶
DispatchFunc 定义了将心跳内容发送到目标会话的函数原型。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 负责定期执行健康探测,并将结果分发到最近活跃的会话中。
func NewService ¶
func NewService(cfg Config, probe ProbeFunc, dispatch DispatchFunc, stateMgr *appstate.Manager) *Service
NewService 创建并初始化一个新的心跳服务。
func (*Service) TrackActivity ¶
TrackActivity 更新并持久化最近活跃的通道与聊天 ID,用于确定心跳发送目标。
Click to show internal directories.
Click to hide internal directories.