From c767f429f03777e27eda0c85ad6e84cf4f852c81 Mon Sep 17 00:00:00 2001 From: xakdwch Date: Fri, 3 Mar 2023 09:50:14 +0800 Subject: [PATCH] rafthttp: replace inline code with existing function The isMsgApp function implements the judgment of the MsgApp message, use the isMsgApp function instead. Signed-off-by: xakdwch --- server/etcdserver/api/rafthttp/pipeline.go | 4 ++-- server/etcdserver/api/rafthttp/transport.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/etcdserver/api/rafthttp/pipeline.go b/server/etcdserver/api/rafthttp/pipeline.go index b8ff3dfca..958d8def2 100644 --- a/server/etcdserver/api/rafthttp/pipeline.go +++ b/server/etcdserver/api/rafthttp/pipeline.go @@ -103,7 +103,7 @@ func (p *pipeline) handle() { if err != nil { p.status.deactivate(failureType{source: pipelineMsg, action: "write"}, err.Error()) - if m.Type == raftpb.MsgApp && p.followerStats != nil { + if isMsgApp(m) && p.followerStats != nil { p.followerStats.Fail() } p.raft.ReportUnreachable(m.To) @@ -115,7 +115,7 @@ func (p *pipeline) handle() { } p.status.activate() - if m.Type == raftpb.MsgApp && p.followerStats != nil { + if isMsgApp(m) && p.followerStats != nil { p.followerStats.Succ(end.Sub(start)) } if isMsgSnap(m) { diff --git a/server/etcdserver/api/rafthttp/transport.go b/server/etcdserver/api/rafthttp/transport.go index f4af5f3c2..339c5734b 100644 --- a/server/etcdserver/api/rafthttp/transport.go +++ b/server/etcdserver/api/rafthttp/transport.go @@ -186,7 +186,7 @@ func (t *Transport) Send(msgs []raftpb.Message) { t.mu.RUnlock() if pok { - if m.Type == raftpb.MsgApp { + if isMsgApp(m) { t.ServerStats.SendAppendReq(m.Size()) } p.send(m)