Skip to content

Commit

Permalink
feat: remove session when send heart beat message failed (#738)
Browse files Browse the repository at this point in the history
* feat:add more linter

* feat:change golangclilint version to 1.57.x to support more linter

* feat:adjust lint conf and adjust the code to pass the check

* feat:close session when send heart beat message failed

---------

Co-authored-by: JayLiu <[email protected]>
  • Loading branch information
No-SilverBullet and luky116 authored Dec 14, 2024
1 parent 9b5b080 commit 1d1214d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/remoting/getty/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,22 @@ func (g *gettyClientHandler) OnMessage(session getty.Session, pkg interface{}) {

func (g *gettyClientHandler) OnCron(session getty.Session) {
log.Debug("session{%s} Oncron executing", session.Stat())
g.transferBeatHeart(session, message.HeartBeatMessagePing)
err := g.transferHeartBeat(session, message.HeartBeatMessagePing)
if err != nil {
log.Errorf("failed to send heart beat: {%#v}", err.Error())
g.sessionManager.releaseSession(session)
}
}

func (g *gettyClientHandler) transferBeatHeart(session getty.Session, msg message.HeartBeatMessage) {
func (g *gettyClientHandler) transferHeartBeat(session getty.Session, msg message.HeartBeatMessage) error {
rpcMessage := message.RpcMessage{
ID: int32(g.idGenerator.Inc()),
Type: message.GettyRequestTypeHeartbeatRequest,
Codec: byte(codec.CodecTypeSeata),
Compressor: 0,
Body: msg,
}
GetGettyRemotingInstance().SendASync(rpcMessage, session, nil)
return GetGettyRemotingInstance().SendASync(rpcMessage, session, nil)
}

func (g *gettyClientHandler) RegisterProcessor(msgType message.MessageType, processor processor.RemotingProcessor) {
Expand Down

0 comments on commit 1d1214d

Please sign in to comment.