diff --git a/server/embed/etcd.go b/server/embed/etcd.go index d3036bc2ae7..42b9b78b945 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -639,7 +639,7 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro } for _, u := range cfg.ListenClientUrls { - addr, secure, network := resolveUrl(u) + addr, secure, network := resolveURL(u) sctx := sctxs[addr] if sctx == nil { sctx = newServeCtx(cfg.logger) @@ -652,7 +652,7 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro sctx.network = network } for _, u := range cfg.ListenClientHttpUrls { - addr, secure, network := resolveUrl(u) + addr, secure, network := resolveURL(u) sctx := sctxs[addr] if sctx == nil { @@ -715,7 +715,7 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro return sctxs, nil } -func resolveUrl(u url.URL) (addr string, secure bool, network string) { +func resolveURL(u url.URL) (addr string, secure bool, network string) { addr = u.Host network = "tcp" if u.Scheme == "unix" || u.Scheme == "unixs" { @@ -757,26 +757,26 @@ func (e *Etcd) serveClients() { })) } - splitHttp := false + splitHTTP := false for _, sctx := range e.sctxs { if sctx.httpOnly { - splitHttp = true + splitHTTP = true } } // start client servers in each goroutine for _, sctx := range e.sctxs { go func(s *serveCtx) { - e.errHandler(s.serve(e.Server, &e.cfg.ClientTLSInfo, mux, e.errHandler, e.grpcGatewayDial(splitHttp), splitHttp, gopts...)) + e.errHandler(s.serve(e.Server, &e.cfg.ClientTLSInfo, mux, e.errHandler, e.grpcGatewayDial(splitHTTP), splitHTTP, gopts...)) }(sctx) } } -func (e *Etcd) grpcGatewayDial(splitHttp bool) (grpcDial func(ctx context.Context) (*grpc.ClientConn, error)) { +func (e *Etcd) grpcGatewayDial(splitHTTP bool) (grpcDial func(ctx context.Context) (*grpc.ClientConn, error)) { if !e.cfg.EnableGRPCGateway { return nil } - sctx := e.pickGrpcGatewayServeContext(splitHttp) + sctx := e.pickGRPCGatewayServeContext(splitHTTP) addr := sctx.addr if network := sctx.network; network == "unix" { // explicitly define unix network for gRPC socket support @@ -808,9 +808,9 @@ func (e *Etcd) grpcGatewayDial(splitHttp bool) (grpcDial func(ctx context.Contex } } -func (e *Etcd) pickGrpcGatewayServeContext(splitHttp bool) *serveCtx { +func (e *Etcd) pickGRPCGatewayServeContext(splitHTTP bool) *serveCtx { for _, sctx := range e.sctxs { - if !splitHttp || !sctx.httpOnly { + if !splitHTTP || !sctx.httpOnly { return sctx } } diff --git a/server/embed/serve.go b/server/embed/serve.go index 8b64cd77ead..7f1a221974f 100644 --- a/server/embed/serve.go +++ b/server/embed/serve.go @@ -96,7 +96,7 @@ func (sctx *serveCtx) serve( handler http.Handler, errHandler func(error), grpcDialForRestGatewayBackends func(ctx context.Context) (*grpc.ClientConn, error), - splitHttp bool, + splitHTTP bool, gopts ...grpc.ServerOption) (err error) { logger := defaultLog.New(io.Discard, "etcdhttp", 0) <-s.ReadyNotify() @@ -105,9 +105,9 @@ func (sctx *serveCtx) serve( m := cmux.New(sctx.l) var server func() error - onlyGRPC := splitHttp && !sctx.httpOnly - onlyHttp := splitHttp && sctx.httpOnly - grpcEnabled := !onlyHttp + onlyGRPC := splitHTTP && !sctx.httpOnly + onlyHTTP := splitHTTP && sctx.httpOnly + grpcEnabled := !onlyHTTP httpEnabled := !onlyGRPC v3c := v3client.New(s) @@ -129,7 +129,7 @@ func (sctx *serveCtx) serve( switch { case onlyGRPC: traffic = "grpc" - case onlyHttp: + case onlyHTTP: traffic = "http" default: traffic = "grpc+http" @@ -144,7 +144,7 @@ func (sctx *serveCtx) serve( Handler: createAccessController(sctx.lg, s, httpmux), ErrorLog: logger, // do not log user error } - if err = configureHttpServer(srv, s.Cfg); err != nil { + if err = configureHTTPServer(srv, s.Cfg); err != nil { sctx.lg.Error("Configure http server failed", zap.Error(err)) return err } @@ -227,7 +227,7 @@ func (sctx *serveCtx) serve( TLSConfig: tlscfg, ErrorLog: logger, // do not log user error } - if err := configureHttpServer(srv, s.Cfg); err != nil { + if err := configureHTTPServer(srv, s.Cfg); err != nil { sctx.lg.Error("Configure https server failed", zap.Error(err)) return err } @@ -258,7 +258,7 @@ func (sctx *serveCtx) serve( return server() } -func configureHttpServer(srv *http.Server, cfg config.ServerConfig) error { +func configureHTTPServer(srv *http.Server, cfg config.ServerConfig) error { // todo (ahrtr): should we support configuring other parameters in the future as well? return http2.ConfigureServer(srv, &http2.Server{ MaxConcurrentStreams: cfg.MaxConcurrentStreams, diff --git a/server/mock/mockstore/store_recorder.go b/server/mock/mockstore/store_recorder.go index deb827f94e7..b92d0d0e360 100644 --- a/server/mock/mockstore/store_recorder.go +++ b/server/mock/mockstore/store_recorder.go @@ -119,7 +119,11 @@ func (s *storeRecorder) Clone() v2store.Store { return s } +//revive:disable:var-naming func (s *storeRecorder) JsonStats() []byte { return nil } + +//revive:enable:var-naming + func (s *storeRecorder) DeleteExpiredKeys(cutoff time.Time) { s.Record(testutil.Action{ Name: "DeleteExpiredKeys", diff --git a/server/storage/backend/verify.go b/server/storage/backend/verify.go index fc43523a99b..a3aa165fe84 100644 --- a/server/storage/backend/verify.go +++ b/server/storage/backend/verify.go @@ -26,7 +26,7 @@ import ( ) const ( - ENV_VERIFY_VALUE_LOCK verify.VerificationType = "lock" + EnvVerifyValueLock verify.VerificationType = "lock" ) func ValidateCalledInsideApply(lg *zap.Logger) { @@ -57,7 +57,7 @@ func ValidateCalledInsideUnittest(lg *zap.Logger) { } func verifyLockEnabled() bool { - return verify.IsVerificationEnabled(ENV_VERIFY_VALUE_LOCK) + return verify.IsVerificationEnabled(EnvVerifyValueLock) } func insideApply() bool { diff --git a/server/storage/backend/verify_test.go b/server/storage/backend/verify_test.go index 5f32f5721f3..6ea7baf8b3d 100644 --- a/server/storage/backend/verify_test.go +++ b/server/storage/backend/verify_test.go @@ -69,7 +69,7 @@ func TestLockVerify(t *testing.T) { expectPanic: false, }, } - revertVerifyFunc := verify.EnableVerifications(backend.ENV_VERIFY_VALUE_LOCK) + revertVerifyFunc := verify.EnableVerifications(backend.EnvVerifyValueLock) defer revertVerifyFunc() for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { diff --git a/server/storage/schema/lease.go b/server/storage/schema/lease.go index 3ffeec64015..de29f30fc49 100644 --- a/server/storage/schema/lease.go +++ b/server/storage/schema/lease.go @@ -44,7 +44,7 @@ func MustUnsafeGetAllLeases(tx backend.UnsafeReader) []*leasepb.Lease { } func MustUnsafePutLease(tx backend.UnsafeWriter, lpb *leasepb.Lease) { - key := leaseIdToBytes(lpb.ID) + key := leaseIDToBytes(lpb.ID) val, err := lpb.Marshal() if err != nil { @@ -54,11 +54,11 @@ func MustUnsafePutLease(tx backend.UnsafeWriter, lpb *leasepb.Lease) { } func UnsafeDeleteLease(tx backend.UnsafeWriter, lpb *leasepb.Lease) { - tx.UnsafeDelete(Lease, leaseIdToBytes(lpb.ID)) + tx.UnsafeDelete(Lease, leaseIDToBytes(lpb.ID)) } func MustUnsafeGetLease(tx backend.UnsafeReader, leaseID int64) *leasepb.Lease { - _, vs := tx.UnsafeRange(Lease, leaseIdToBytes(leaseID), nil, 0) + _, vs := tx.UnsafeRange(Lease, leaseIDToBytes(leaseID), nil, 0) if len(vs) != 1 { return nil } @@ -70,7 +70,7 @@ func MustUnsafeGetLease(tx backend.UnsafeReader, leaseID int64) *leasepb.Lease { return &lpb } -func leaseIdToBytes(n int64) []byte { +func leaseIDToBytes(n int64) []byte { bytes := make([]byte, 8) binary.BigEndian.PutUint64(bytes, uint64(n)) return bytes diff --git a/server/storage/schema/membership.go b/server/storage/schema/membership.go index 44e2af1cd7f..0ee6fc66770 100644 --- a/server/storage/schema/membership.go +++ b/server/storage/schema/membership.go @@ -93,12 +93,12 @@ func (s *membershipBackend) readMembersFromBackend() (map[types.ID]*membership.M tx.RLock() defer tx.RUnlock() err := tx.UnsafeForEach(Members, func(k, v []byte) error { - memberId := mustParseMemberIDFromBytes(s.lg, k) - m := &membership.Member{ID: memberId} + memberID := mustParseMemberIDFromBytes(s.lg, k) + m := &membership.Member{ID: memberID} if err := json.Unmarshal(v, &m); err != nil { return err } - members[memberId] = m + members[memberID] = m return nil }) if err != nil { @@ -106,8 +106,8 @@ func (s *membershipBackend) readMembersFromBackend() (map[types.ID]*membership.M } err = tx.UnsafeForEach(MembersRemoved, func(k, v []byte) error { - memberId := mustParseMemberIDFromBytes(s.lg, k) - removed[memberId] = true + memberID := mustParseMemberIDFromBytes(s.lg, k) + removed[memberID] = true return nil }) if err != nil { diff --git a/server/storage/wal/util.go b/server/storage/wal/util.go index f9e6b5fd160..8dec85c15d5 100644 --- a/server/storage/wal/util.go +++ b/server/storage/wal/util.go @@ -74,14 +74,14 @@ func readWALNames(lg *zap.Logger, dirpath string) ([]string, error) { if err != nil { return nil, fmt.Errorf("[readWALNames] fileutil.ReadDir failed: %w", err) } - wnames := checkWalNames(lg, names) + wnames := checkWALNames(lg, names) if len(wnames) == 0 { return nil, ErrFileNotFound } return wnames, nil } -func checkWalNames(lg *zap.Logger, names []string) []string { +func checkWALNames(lg *zap.Logger, names []string) []string { wnames := make([]string, 0) for _, name := range names { if _, _, err := parseWALName(name); err != nil { diff --git a/server/verify/verify.go b/server/verify/verify.go index 498f0d56b3c..5fce8b28a07 100644 --- a/server/verify/verify.go +++ b/server/verify/verify.go @@ -29,7 +29,7 @@ import ( "go.etcd.io/raft/v3/raftpb" ) -const ENV_VERIFY_VALUE_STORAGE_WAL verify.VerificationType = "storage_wal" +const envVerifyValueStorageWAL verify.VerificationType = "storage_wal" type Config struct { // DataDir is a root directory where the data being verified are stored. @@ -77,7 +77,7 @@ func Verify(cfg Config) (retErr error) { be := backend.NewDefaultBackend(lg, datadir.ToBackendFileName(cfg.DataDir)) defer be.Close() - snapshot, hardstate, err := validateWal(cfg) + snapshot, hardstate, err := validateWAL(cfg) if err != nil { return err } @@ -91,7 +91,7 @@ func Verify(cfg Config) (retErr error) { // VerifyIfEnabled performs verification according to ETCD_VERIFY env settings. // See Verify for more information. func VerifyIfEnabled(cfg Config) error { - if verify.IsVerificationEnabled(ENV_VERIFY_VALUE_STORAGE_WAL) { + if verify.IsVerificationEnabled(envVerifyValueStorageWAL) { return Verify(cfg) } return nil @@ -131,7 +131,7 @@ func validateConsistentIndex(cfg Config, hardstate *raftpb.HardState, snapshot * return nil } -func validateWal(cfg Config) (*walpb.Snapshot, *raftpb.HardState, error) { +func validateWAL(cfg Config) (*walpb.Snapshot, *raftpb.HardState, error) { walDir := datadir.ToWalDir(cfg.DataDir) walSnaps, err := wal2.ValidSnapshotEntries(cfg.Logger, walDir)