StartHeartBeat starts the heartbeat check. interval is the time interval between each heartbeat. (启动心跳检测 interval 每次发送心跳的时间间隔)
(interval time.Duration)
| 542 | // (启动心跳检测 |
| 543 | // interval 每次发送心跳的时间间隔) |
| 544 | func (s *Server) StartHeartBeat(interval time.Duration) { |
| 545 | checker := NewHeartbeatChecker(interval) |
| 546 | |
| 547 | // Add the heartbeat check router. (添加心跳检测的路由) |
| 548 | //检测当前路由模式 |
| 549 | if s.RouterSlicesMode { |
| 550 | s.AddRouterSlices(checker.MsgID(), checker.RouterSlices()...) |
| 551 | } else { |
| 552 | s.AddRouter(checker.MsgID(), checker.Router()) |
| 553 | } |
| 554 | |
| 555 | // Bind the heartbeat checker to the server. (server绑定心跳检测器) |
| 556 | s.hc = checker |
| 557 | } |
| 558 | |
| 559 | // StartHeartBeatWithOption starts the heartbeat detection with the given configuration. |
| 560 | // interval is the time interval for sending heartbeat messages. |
no test coverage detected