This is an automated email from the ASF dual-hosted git repository. luky116 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-seata-go.git
The following commit(s) were added to refs/heads/master by this push: new 1d1214de feat: remove session when send heart beat message failed (#738) 1d1214de is described below commit 1d1214deb192a3d65d626180b71cded19ffceca8 Author: xinfan.wu <xinfan...@xgimi.com> AuthorDate: Sat Dec 14 16:27:03 2024 +0800 feat: remove session when send heart beat message failed (#738) * 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 <38887641+luky...@users.noreply.github.com> --- pkg/remoting/getty/listener.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/remoting/getty/listener.go b/pkg/remoting/getty/listener.go index f5ba96ff..2f2e9748 100644 --- a/pkg/remoting/getty/listener.go +++ b/pkg/remoting/getty/listener.go @@ -115,10 +115,14 @@ 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, @@ -126,7 +130,7 @@ func (g *gettyClientHandler) transferBeatHeart(session getty.Session, msg messag 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) { --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org