Skip to content

Commit

Permalink
delete master peers when master disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
snowinszu committed Jan 6, 2021
1 parent 839fc24 commit 4c9bf06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version: 2.0.0
version: 2.0.1

log:
writers: file # 输出位置,有两个可选项 —— file 和 stdout。选择 file 会将日志记录到 logger_file 指定的日志文件中,选择 stdout 会将日志输出到标准输出,当然也可以两者同时选择
Expand Down
2 changes: 1 addition & 1 deletion config_cluster.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version: 2.0.0
version: 2.0.1

log:
writers: file # 输出位置,有两个可选项 —— file 和 stdout。选择 file 会将日志记录到 logger_file 指定的日志文件中,选择 stdout 会将日志输出到标准输出,当然也可以两者同时选择
Expand Down
4 changes: 4 additions & 0 deletions rpcservice/heartbeat/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func (h *Client) StartHeartbeat() {
log.Errorf(err, "heartbeat")
// master失去联系
h.IsMasterAlive = false
// 将master节点对应的peers删除
go deletePeersInNode(h.masterAddr)
h.DialHeartbeatService()
}
log.Infof("heartbeatResp %s", heartbeatResp)
Expand Down Expand Up @@ -132,6 +134,8 @@ func (h *Client) StartHeartbeat() {
}()
}



func deletePeersInNode(addr string) {
hub.GetInstance().Clients.Range(func(peerId, peer interface{}) bool {
cli := peer.(*client.Client)
Expand Down

0 comments on commit 4c9bf06

Please sign in to comment.