From 75c46fc5de7c48d3f4101cf42b7e57d6b079aa84 Mon Sep 17 00:00:00 2001 From: PotatoCloud <60210021+PotatoCloud@users.noreply.github.com> Date: Wed, 3 Jan 2024 19:25:02 +0800 Subject: [PATCH] [Server::patch] stash --- raft.go | 6 +++--- server.go | 2 +- v1_server.go | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/raft.go b/raft.go index b2d887c..c7884a2 100644 --- a/raft.go +++ b/raft.go @@ -85,7 +85,7 @@ func RaftWithBoltLogStore(path string) RaftServerOption { return func(r *Raft) (err error) { r.logStore, err = raftboltdb.NewBoltStore(path) if err != nil { - return errors.Wrap(err, "bolt-log-Store") + return errors.Wrap(err, "bolt-log-store") } return } @@ -95,7 +95,7 @@ func RaftWithStdStableStore(store store.Store) RaftServerOption { return func(r *Raft) (err error) { r.stableStore, err = NewStableStore(store) if err != nil { - return errors.Wrap(err, "std-stable-Store") + return errors.Wrap(err, "std-stable-store") } return } @@ -105,7 +105,7 @@ func RaftWithFileSnapshotStore(path string, retain int, logOut io.Writer) RaftSe return func(r *Raft) (err error) { r.snapshotStore, err = raft.NewFileSnapshotStore(path, retain, logOut) if err != nil { - return errors.Wrap(err, "file-snapshot-Store") + return errors.Wrap(err, "file-snapshot-store") } return } diff --git a/server.go b/server.go index 047accd..4ad7f3e 100644 --- a/server.go +++ b/server.go @@ -123,7 +123,7 @@ func NewServer(cfg *config.Config) (*Server, error) { go server.pprofServer.Run() } - // init server Store backend + // init server store backend if server.store, err = newStoreBackend(cfg.Store, cfg.Node.DataDir); err != nil { return nil, err } diff --git a/v1_server.go b/v1_server.go index 35dde91..48b5eb9 100644 --- a/v1_server.go +++ b/v1_server.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/raft" "google.golang.org/protobuf/types/known/emptypb" "io" - "sync/atomic" "time" "google.golang.org/grpc/codes" @@ -43,7 +42,7 @@ type Internal interface { func (s *Server) responseHeader() *serverpb.ResponseHeader { return &serverpb.ResponseHeader{ ClusterId: s.clusterID, - RaftTerm: atomic.LoadUint64(&s.term), + RaftTerm: s.raft.Term(), } }