Use any instead of interface{}

Signed-off-by: chenyahui <cyhone@qq.com>
This commit is contained in:
chenyahui 2023-09-17 17:41:58 +08:00
parent fb8a315be6
commit c0aa3b613b
61 changed files with 227 additions and 227 deletions

View File

@ -41,7 +41,7 @@ var (
// oneShotCtxValue is set on a context using WithValue(&oneShotValue) so // oneShotCtxValue is set on a context using WithValue(&oneShotValue) so
// that Do() will not retry a request // that Do() will not retry a request
oneShotCtxValue interface{} oneShotCtxValue any
) )
var DefaultRequestTimeout = 5 * time.Second var DefaultRequestTimeout = 5 * time.Second

View File

@ -496,8 +496,8 @@ func (f fakeCancelContext) Done() <-chan struct{} {
d <- struct{}{} d <- struct{}{}
return d return d
} }
func (f fakeCancelContext) Err() error { return errFakeCancelContext } func (f fakeCancelContext) Err() error { return errFakeCancelContext }
func (f fakeCancelContext) Value(key interface{}) interface{} { return 1 } func (f fakeCancelContext) Value(key any) any { return 1 }
func withTimeout(parent context.Context, timeout time.Duration) ( func withTimeout(parent context.Context, timeout time.Duration) (
ctx context.Context, ctx context.Context,

View File

@ -21,20 +21,20 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func copyToInterface(msg ...string) []interface{} { func copyToInterface(msg ...string) []any {
newMsg := make([]interface{}, len(msg)) newMsg := make([]any, len(msg))
for i, v := range msg { for i, v := range msg {
newMsg[i] = v newMsg[i] = v
} }
return newMsg return newMsg
} }
func AssertNil(t *testing.T, v interface{}) { func AssertNil(t *testing.T, v any) {
t.Helper() t.Helper()
assert.Nil(t, v) assert.Nil(t, v)
} }
func AssertNotNil(t *testing.T, v interface{}) { func AssertNotNil(t *testing.T, v any) {
t.Helper() t.Helper()
if v == nil { if v == nil {
t.Fatalf("expected non-nil, got %+v", v) t.Fatalf("expected non-nil, got %+v", v)
@ -53,7 +53,7 @@ func AssertFalse(t *testing.T, v bool, msg ...string) {
assert.Equal(t, false, v, newMsg) assert.Equal(t, false, v, newMsg)
} }
func isNil(v interface{}) bool { func isNil(v any) bool {
if v == nil { if v == nil {
return true return true
} }

View File

@ -23,7 +23,7 @@ import (
type Action struct { type Action struct {
Name string Name string
Params []interface{} Params []any
} }
type Recorder interface { type Recorder interface {

View File

@ -23,18 +23,18 @@ import (
// We cannot implement testing.TB due to protection, so we expose this simplified interface. // We cannot implement testing.TB due to protection, so we expose this simplified interface.
type TB interface { type TB interface {
Cleanup(func()) Cleanup(func())
Error(args ...interface{}) Error(args ...any)
Errorf(format string, args ...interface{}) Errorf(format string, args ...any)
Fail() Fail()
FailNow() FailNow()
Failed() bool Failed() bool
Fatal(args ...interface{}) Fatal(args ...any)
Fatalf(format string, args ...interface{}) Fatalf(format string, args ...any)
Logf(format string, args ...interface{}) Logf(format string, args ...any)
Name() string Name() string
TempDir() string TempDir() string
Helper() Helper()
Skip(args ...interface{}) Skip(args ...any)
} }
// NewTestingTBProthesis creates a fake variant of testing.TB implementation. // NewTestingTBProthesis creates a fake variant of testing.TB implementation.
@ -59,20 +59,20 @@ func (t *testingTBProthesis) Helper() {
// Ignored // Ignored
} }
func (t *testingTBProthesis) Skip(args ...interface{}) { func (t *testingTBProthesis) Skip(args ...any) {
t.Log(append([]interface{}{"Skipping due to: "}, args...)) t.Log(append([]any{"Skipping due to: "}, args...))
} }
func (t *testingTBProthesis) Cleanup(f func()) { func (t *testingTBProthesis) Cleanup(f func()) {
t.cleanups = append(t.cleanups, f) t.cleanups = append(t.cleanups, f)
} }
func (t *testingTBProthesis) Error(args ...interface{}) { func (t *testingTBProthesis) Error(args ...any) {
log.Println(args...) log.Println(args...)
t.Fail() t.Fail()
} }
func (t *testingTBProthesis) Errorf(format string, args ...interface{}) { func (t *testingTBProthesis) Errorf(format string, args ...any) {
log.Printf(format, args...) log.Printf(format, args...)
t.Fail() t.Fail()
} }
@ -90,19 +90,19 @@ func (t *testingTBProthesis) Failed() bool {
return t.failed return t.failed
} }
func (t *testingTBProthesis) Fatal(args ...interface{}) { func (t *testingTBProthesis) Fatal(args ...any) {
log.Fatalln(args...) log.Fatalln(args...)
} }
func (t *testingTBProthesis) Fatalf(format string, args ...interface{}) { func (t *testingTBProthesis) Fatalf(format string, args ...any) {
log.Fatalf(format, args...) log.Fatalf(format, args...)
} }
func (t *testingTBProthesis) Logf(format string, args ...interface{}) { func (t *testingTBProthesis) Logf(format string, args ...any) {
log.Printf(format, args...) log.Printf(format, args...)
} }
func (t *testingTBProthesis) Log(args ...interface{}) { func (t *testingTBProthesis) Log(args ...any) {
log.Println(args...) log.Println(args...)
} }

View File

@ -73,7 +73,7 @@ func Verify(f func()) {
} }
// Assert will panic with a given formatted message if the given condition is false. // Assert will panic with a given formatted message if the given condition is false.
func Assert(condition bool, msg string, v ...interface{}) { func Assert(condition bool, msg string, v ...any) {
if !condition { if !condition {
panic(fmt.Sprintf("assertion failed: "+msg, v...)) panic(fmt.Sprintf("assertion failed: "+msg, v...))
} }

View File

@ -30,7 +30,7 @@ const (
type Cmp pb.Compare type Cmp pb.Compare
func Compare(cmp Cmp, result string, v interface{}) Cmp { func Compare(cmp Cmp, result string, v any) Cmp {
var r pb.Compare_CompareResult var r pb.Compare_CompareResult
switch result { switch result {
@ -120,7 +120,7 @@ func (cmp Cmp) WithPrefix() Cmp {
} }
// mustInt64 panics if val isn't an int or int64. It returns an int64 otherwise. // mustInt64 panics if val isn't an int or int64. It returns an int64 otherwise.
func mustInt64(val interface{}) int64 { func mustInt64(val any) int64 {
if v, ok := val.(int64); ok { if v, ok := val.(int64); ok {
return v return v
} }
@ -132,7 +132,7 @@ func mustInt64(val interface{}) int64 {
// mustInt64orLeaseID panics if val isn't a LeaseID, int or int64. It returns an // mustInt64orLeaseID panics if val isn't a LeaseID, int or int64. It returns an
// int64 otherwise. // int64 otherwise.
func mustInt64orLeaseID(val interface{}) int64 { func mustInt64orLeaseID(val any) int64 {
if v, ok := val.(LeaseID); ok { if v, ok := val.(LeaseID); ok {
return int64(v) return int64(v)
} }

View File

@ -32,7 +32,7 @@ type Endpoint struct {
// Metadata is the information associated with Addr, which may be used // Metadata is the information associated with Addr, which may be used
// to make load balancing decision. // to make load balancing decision.
// Since etcd 3.1 // Since etcd 3.1
Metadata interface{} Metadata any
} }
type Operation uint8 type Operation uint8

View File

@ -48,5 +48,5 @@ type Update struct {
// Metadata is the updated metadata. It is nil if there is no metadata update. // Metadata is the updated metadata. It is nil if there is no metadata update.
// Metadata is not required for a custom naming implementation. // Metadata is not required for a custom naming implementation.
// Since etcd 3.1. // Since etcd 3.1.
Metadata interface{} Metadata any
} }

View File

@ -39,7 +39,7 @@ import (
// changed through options (e.g. WithMax) on creation of the interceptor or on call (through grpc.CallOptions). // changed through options (e.g. WithMax) on creation of the interceptor or on call (through grpc.CallOptions).
func (c *Client) unaryClientInterceptor(optFuncs ...retryOption) grpc.UnaryClientInterceptor { func (c *Client) unaryClientInterceptor(optFuncs ...retryOption) grpc.UnaryClientInterceptor {
intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs) intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs)
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
ctx = withVersion(ctx) ctx = withVersion(ctx)
grpcOpts, retryOpts := filterCallOptions(opts) grpcOpts, retryOpts := filterCallOptions(opts)
callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts) callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts)
@ -179,9 +179,9 @@ func (c *Client) refreshToken(ctx context.Context) error {
type serverStreamingRetryingStream struct { type serverStreamingRetryingStream struct {
grpc.ClientStream grpc.ClientStream
client *Client client *Client
bufferedSends []interface{} // single message that the client can sen bufferedSends []any // single message that the client can sen
receivedGood bool // indicates whether any prior receives were successful receivedGood bool // indicates whether any prior receives were successful
wasClosedSend bool // indicates that CloseSend was closed wasClosedSend bool // indicates that CloseSend was closed
ctx context.Context ctx context.Context
callOpts *options callOpts *options
streamerCall func(ctx context.Context) (grpc.ClientStream, error) streamerCall func(ctx context.Context) (grpc.ClientStream, error)
@ -200,7 +200,7 @@ func (s *serverStreamingRetryingStream) getStream() grpc.ClientStream {
return s.ClientStream return s.ClientStream
} }
func (s *serverStreamingRetryingStream) SendMsg(m interface{}) error { func (s *serverStreamingRetryingStream) SendMsg(m any) error {
s.mu.Lock() s.mu.Lock()
s.bufferedSends = append(s.bufferedSends, m) s.bufferedSends = append(s.bufferedSends, m)
s.mu.Unlock() s.mu.Unlock()
@ -222,7 +222,7 @@ func (s *serverStreamingRetryingStream) Trailer() metadata.MD {
return s.getStream().Trailer() return s.getStream().Trailer()
} }
func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error { func (s *serverStreamingRetryingStream) RecvMsg(m any) error {
attemptRetry, lastErr := s.receiveMsgAndIndicateRetry(m) attemptRetry, lastErr := s.receiveMsgAndIndicateRetry(m)
if !attemptRetry { if !attemptRetry {
return lastErr // success or hard failure return lastErr // success or hard failure
@ -249,7 +249,7 @@ func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error {
return lastErr return lastErr
} }
func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m interface{}) (bool, error) { func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m any) (bool, error) {
s.mu.RLock() s.mu.RLock()
wasGood := s.receivedGood wasGood := s.receivedGood
s.mu.RUnlock() s.mu.RUnlock()

View File

@ -92,7 +92,7 @@ func NewPrinter(printerType string, isHex bool) printer {
type printerRPC struct { type printerRPC struct {
printer printer
p func(interface{}) p func(any)
} }
func (p *printerRPC) Del(r v3.DeleteResponse) { p.p((*pb.DeleteRangeResponse)(&r)) } func (p *printerRPC) Del(r v3.DeleteResponse) { p.p((*pb.DeleteRangeResponse)(&r)) }
@ -159,7 +159,7 @@ func (p *printerRPC) AuthStatus(r v3.AuthStatusResponse) {
type printerUnsupported struct{ printerRPC } type printerUnsupported struct{ printerRPC }
func newPrinterUnsupported(n string) printer { func newPrinterUnsupported(n string) printer {
f := func(interface{}) { f := func(any) {
cobrautl.ExitWithError(cobrautl.ExitBadFeature, errors.New(n+" not supported as output format")) cobrautl.ExitWithError(cobrautl.ExitBadFeature, errors.New(n+" not supported as output format"))
} }
return &printerUnsupported{printerRPC{nil, f}} return &printerUnsupported{printerRPC{nil, f}}

View File

@ -48,7 +48,7 @@ func (p *jsonPrinter) MemberList(r clientv3.MemberListResponse) {
} }
} }
func printJSON(v interface{}) { func printJSON(v any) {
b, err := json.Marshal(v) b, err := json.Marshal(v)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err) fmt.Fprintf(os.Stderr, "%v\n", err)

View File

@ -51,7 +51,7 @@ func (p *pbPrinter) Watch(r v3.WatchResponse) {
printPB(&wr) printPB(&wr)
} }
func printPB(v interface{}) { func printPB(v any) {
m, ok := v.(pbMarshal) m, ok := v.(pbMarshal)
if !ok { if !ok {
cobrautl.ExitWithError(cobrautl.ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v)) cobrautl.ExitWithError(cobrautl.ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v))

View File

@ -52,13 +52,13 @@ func NewPrinter(printerType string) printer {
type printerRPC struct { type printerRPC struct {
printer printer
p func(interface{}) p func(any)
} }
type printerUnsupported struct{ printerRPC } type printerUnsupported struct{ printerRPC }
func newPrinterUnsupported(n string) printer { func newPrinterUnsupported(n string) printer {
f := func(interface{}) { f := func(any) {
cobrautl.ExitWithError(cobrautl.ExitBadFeature, errors.New(n+" not supported as output format")) cobrautl.ExitWithError(cobrautl.ExitBadFeature, errors.New(n+" not supported as output format"))
} }
return &printerUnsupported{printerRPC{nil, f}} return &printerUnsupported{printerRPC{nil, f}}

View File

@ -35,7 +35,7 @@ func newJSONPrinter() printer {
func (p *jsonPrinter) DBStatus(r snapshot.Status) { printJSON(r) } func (p *jsonPrinter) DBStatus(r snapshot.Status) { printJSON(r) }
// !!! Share ?? // !!! Share ??
func printJSON(v interface{}) { func printJSON(v any) {
b, err := json.Marshal(v) b, err := json.Marshal(v)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err) fmt.Fprintf(os.Stderr, "%v\n", err)

View File

@ -33,7 +33,7 @@ func newPBPrinter() printer {
} }
} }
func printPB(v interface{}) { func printPB(v any) {
m, ok := v.(pbMarshal) m, ok := v.(pbMarshal)
if !ok { if !ok {
cobrautl.ExitWithError(cobrautl.ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v)) cobrautl.ExitWithError(cobrautl.ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v))

View File

@ -176,7 +176,7 @@ func (x *intervalNode) visit(iv *Interval, sentinel *intervalNode, nv nodeVisito
// IntervalValue represents a range tree node that contains a range and a value. // IntervalValue represents a range tree node that contains a range and a value.
type IntervalValue struct { type IntervalValue struct {
Ivl Interval Ivl Interval
Val interface{} Val any
} }
// IntervalTree represents a (mostly) textbook implementation of the // IntervalTree represents a (mostly) textbook implementation of the
@ -184,7 +184,7 @@ type IntervalValue struct {
// and chapter 14.3 interval tree with search supporting "stabbing queries". // and chapter 14.3 interval tree with search supporting "stabbing queries".
type IntervalTree interface { type IntervalTree interface {
// Insert adds a node with the given interval into the tree. // Insert adds a node with the given interval into the tree.
Insert(ivl Interval, val interface{}) Insert(ivl Interval, val any)
// Delete removes the node with the given interval from the tree, returning // Delete removes the node with the given interval from the tree, returning
// true if a node is in fact removed. // true if a node is in fact removed.
Delete(ivl Interval) bool Delete(ivl Interval) bool
@ -423,7 +423,7 @@ func (ivt *intervalTree) deleteFixup(x *intervalNode) {
} }
} }
func (ivt *intervalTree) createIntervalNode(ivl Interval, val interface{}) *intervalNode { func (ivt *intervalTree) createIntervalNode(ivl Interval, val any) *intervalNode {
return &intervalNode{ return &intervalNode{
iv: IntervalValue{ivl, val}, iv: IntervalValue{ivl, val},
max: ivl.End, max: ivl.End,
@ -466,7 +466,7 @@ func (ivt *intervalTree) createIntervalNode(ivl Interval, val interface{}) *inte
// RB-INSERT-FIXUP(T, z) // RB-INSERT-FIXUP(T, z)
// Insert adds a node with the given interval into the tree. // Insert adds a node with the given interval into the tree.
func (ivt *intervalTree) Insert(ivl Interval, val interface{}) { func (ivt *intervalTree) Insert(ivl Interval, val any) {
y := ivt.sentinel y := ivt.sentinel
z := ivt.createIntervalNode(ivl, val) z := ivt.createIntervalNode(ivl, val)
x := ivt.root x := ivt.root

View File

@ -33,7 +33,7 @@ type RequestInfo struct {
} }
func (ri *GrpcRecorder) UnaryInterceptor() grpc.UnaryServerInterceptor { func (ri *GrpcRecorder) UnaryInterceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
ri.record(toRequestInfo(ctx, info)) ri.record(toRequestInfo(ctx, info))
resp, err := handler(ctx, req) resp, err := handler(ctx, req)
return resp, err return resp, err

View File

@ -33,7 +33,7 @@ const (
// Field is a kv pair to record additional details of the trace. // Field is a kv pair to record additional details of the trace.
type Field struct { type Field struct {
Key string Key string
Value interface{} Value any
} }
func (f *Field) format() string { func (f *Field) format() string {

View File

@ -34,9 +34,9 @@ type Wait interface {
// Register waits returns a chan that waits on the given ID. // Register waits returns a chan that waits on the given ID.
// The chan will be triggered when Trigger is called with // The chan will be triggered when Trigger is called with
// the same ID. // the same ID.
Register(id uint64) <-chan interface{} Register(id uint64) <-chan any
// Trigger triggers the waiting chans with the given ID. // Trigger triggers the waiting chans with the given ID.
Trigger(id uint64, x interface{}) Trigger(id uint64, x any)
IsRegistered(id uint64) bool IsRegistered(id uint64) bool
} }
@ -46,7 +46,7 @@ type list struct {
type listElement struct { type listElement struct {
l sync.RWMutex l sync.RWMutex
m map[uint64]chan interface{} m map[uint64]chan any
} }
// New creates a Wait. // New creates a Wait.
@ -55,14 +55,14 @@ func New() Wait {
e: make([]listElement, defaultListElementLength), e: make([]listElement, defaultListElementLength),
} }
for i := 0; i < len(res.e); i++ { for i := 0; i < len(res.e); i++ {
res.e[i].m = make(map[uint64]chan interface{}) res.e[i].m = make(map[uint64]chan any)
} }
return &res return &res
} }
func (w *list) Register(id uint64) <-chan interface{} { func (w *list) Register(id uint64) <-chan any {
idx := id % defaultListElementLength idx := id % defaultListElementLength
newCh := make(chan interface{}, 1) newCh := make(chan any, 1)
w.e[idx].l.Lock() w.e[idx].l.Lock()
defer w.e[idx].l.Unlock() defer w.e[idx].l.Unlock()
if _, ok := w.e[idx].m[id]; !ok { if _, ok := w.e[idx].m[id]; !ok {
@ -73,7 +73,7 @@ func (w *list) Register(id uint64) <-chan interface{} {
return newCh return newCh
} }
func (w *list) Trigger(id uint64, x interface{}) { func (w *list) Trigger(id uint64, x any) {
idx := id % defaultListElementLength idx := id % defaultListElementLength
w.e[idx].l.Lock() w.e[idx].l.Lock()
ch := w.e[idx].m[id] ch := w.e[idx].m[id]
@ -94,17 +94,17 @@ func (w *list) IsRegistered(id uint64) bool {
} }
type waitWithResponse struct { type waitWithResponse struct {
ch <-chan interface{} ch <-chan any
} }
func NewWithResponse(ch <-chan interface{}) Wait { func NewWithResponse(ch <-chan any) Wait {
return &waitWithResponse{ch: ch} return &waitWithResponse{ch: ch}
} }
func (w *waitWithResponse) Register(id uint64) <-chan interface{} { func (w *waitWithResponse) Register(id uint64) <-chan any {
return w.ch return w.ch
} }
func (w *waitWithResponse) Trigger(id uint64, x interface{}) {} func (w *waitWithResponse) Trigger(id uint64, x any) {}
func (w *waitWithResponse) IsRegistered(id uint64) bool { func (w *waitWithResponse) IsRegistered(id uint64) bool {
panic("waitWithResponse.IsRegistered() shouldn't be called") panic("waitWithResponse.IsRegistered() shouldn't be called")
} }

View File

@ -29,7 +29,7 @@ import (
type tokenJWT struct { type tokenJWT struct {
lg *zap.Logger lg *zap.Logger
signMethod jwt.SigningMethod signMethod jwt.SigningMethod
key interface{} key any
ttl time.Duration ttl time.Duration
verifyOnly bool verifyOnly bool
} }
@ -46,7 +46,7 @@ func (t *tokenJWT) info(ctx context.Context, token string, rev uint64) (*AuthInf
revision float64 revision float64
) )
parsed, err := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) { parsed, err := jwt.Parse(token, func(token *jwt.Token) (any, error) {
if token.Method.Alg() != t.signMethod.Alg() { if token.Method.Alg() != t.signMethod.Alg() {
return nil, errors.New("invalid signing method") return nil, errors.New("invalid signing method")
} }

View File

@ -96,7 +96,7 @@ func (opts *jwtOptions) Parse(optMap map[string]string) error {
} }
// Key will parse and return the appropriately typed key for the selected signature method // Key will parse and return the appropriately typed key for the selected signature method
func (opts *jwtOptions) Key() (interface{}, error) { func (opts *jwtOptions) Key() (any, error) {
switch opts.SignMethod.(type) { switch opts.SignMethod.(type) {
case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS: case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS:
return opts.rsaKey() return opts.rsaKey()
@ -111,14 +111,14 @@ func (opts *jwtOptions) Key() (interface{}, error) {
} }
} }
func (opts *jwtOptions) hmacKey() (interface{}, error) { func (opts *jwtOptions) hmacKey() (any, error) {
if len(opts.PrivateKey) == 0 { if len(opts.PrivateKey) == 0 {
return nil, ErrMissingKey return nil, ErrMissingKey
} }
return opts.PrivateKey, nil return opts.PrivateKey, nil
} }
func (opts *jwtOptions) rsaKey() (interface{}, error) { func (opts *jwtOptions) rsaKey() (any, error) {
var ( var (
priv *rsa.PrivateKey priv *rsa.PrivateKey
pub *rsa.PublicKey pub *rsa.PublicKey
@ -156,7 +156,7 @@ func (opts *jwtOptions) rsaKey() (interface{}, error) {
return priv, nil return priv, nil
} }
func (opts *jwtOptions) ecKey() (interface{}, error) { func (opts *jwtOptions) ecKey() (any, error) {
var ( var (
priv *ecdsa.PrivateKey priv *ecdsa.PrivateKey
pub *ecdsa.PublicKey pub *ecdsa.PublicKey
@ -194,7 +194,7 @@ func (opts *jwtOptions) ecKey() (interface{}, error) {
return priv, nil return priv, nil
} }
func (opts *jwtOptions) edKey() (interface{}, error) { func (opts *jwtOptions) edKey() (any, error) {
var ( var (
priv ed25519.PrivateKey priv ed25519.PrivateKey
pub ed25519.PublicKey pub ed25519.PublicKey

View File

@ -336,11 +336,11 @@ type wsProxyZapLogger struct {
*zap.Logger *zap.Logger
} }
func (w wsProxyZapLogger) Warnln(i ...interface{}) { func (w wsProxyZapLogger) Warnln(i ...any) {
w.Warn(fmt.Sprint(i...)) w.Warn(fmt.Sprint(i...))
} }
func (w wsProxyZapLogger) Debugln(i ...interface{}) { func (w wsProxyZapLogger) Debugln(i ...any) {
w.Debug(fmt.Sprint(i...)) w.Debug(fmt.Sprint(i...))
} }

View File

@ -448,7 +448,7 @@ func newGRPCProxyServer(lg *zap.Logger, client *clientv3.Client) *grpc.Server {
electionp := grpcproxy.NewElectionProxy(client) electionp := grpcproxy.NewElectionProxy(client)
lockp := grpcproxy.NewLockProxy(client) lockp := grpcproxy.NewLockProxy(client)
alwaysLoggingDeciderServer := func(ctx context.Context, fullMethodName string, servingObject interface{}) bool { return true } alwaysLoggingDeciderServer := func(ctx context.Context, fullMethodName string, servingObject any) bool { return true }
grpcChainStreamList := []grpc.StreamServerInterceptor{ grpcChainStreamList := []grpc.StreamServerInterceptor{
grpc_prometheus.StreamServerInterceptor, grpc_prometheus.StreamServerInterceptor,

View File

@ -523,7 +523,7 @@ func TestClusterAddMember(t *testing.T) {
wactions := []testutil.Action{ wactions := []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{ Params: []any{
path.Join(StoreMembersPrefix, "1", "raftAttributes"), path.Join(StoreMembersPrefix, "1", "raftAttributes"),
false, false,
`{"peerURLs":null}`, `{"peerURLs":null}`,
@ -546,7 +546,7 @@ func TestClusterAddMemberAsLearner(t *testing.T) {
wactions := []testutil.Action{ wactions := []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{ Params: []any{
path.Join(StoreMembersPrefix, "1", "raftAttributes"), path.Join(StoreMembersPrefix, "1", "raftAttributes"),
false, false,
`{"peerURLs":null,"isLearner":true}`, `{"peerURLs":null,"isLearner":true}`,
@ -587,8 +587,8 @@ func TestClusterRemoveMember(t *testing.T) {
c.RemoveMember(1, true) c.RemoveMember(1, true)
wactions := []testutil.Action{ wactions := []testutil.Action{
{Name: "Delete", Params: []interface{}{MemberStoreKey(1), true, true}}, {Name: "Delete", Params: []any{MemberStoreKey(1), true, true}},
{Name: "Create", Params: []interface{}{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}}, {Name: "Create", Params: []any{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}},
} }
if !reflect.DeepEqual(st.Action(), wactions) { if !reflect.DeepEqual(st.Action(), wactions) {
t.Errorf("actions = %v, want %v", st.Action(), wactions) t.Errorf("actions = %v, want %v", st.Action(), wactions)

View File

@ -276,7 +276,7 @@ func (t *respRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
t.mu.Lock() t.mu.Lock()
defer t.mu.Unlock() defer t.mu.Unlock()
if t.rec != nil { if t.rec != nil {
t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}}) t.rec.Record(testutil.Action{Name: "req", Params: []any{req}})
} }
return &http.Response{StatusCode: t.code, Header: t.header, Body: &nopReadCloser{}}, t.err return &http.Response{StatusCode: t.code, Header: t.header, Body: &nopReadCloser{}}, t.err
} }
@ -287,7 +287,7 @@ type roundTripperRecorder struct {
func (t *roundTripperRecorder) RoundTrip(req *http.Request) (*http.Response, error) { func (t *roundTripperRecorder) RoundTrip(req *http.Request) (*http.Response, error) {
if t.rec != nil { if t.rec != nil {
t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}}) t.rec.Record(testutil.Action{Name: "req", Params: []any{req}})
} }
return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil
} }

View File

@ -174,7 +174,7 @@ func BenchmarkWatchOneKey(b *testing.B) {
} }
} }
func benchStoreSet(b *testing.B, valueSize int, process func(interface{}) ([]byte, error)) { func benchStoreSet(b *testing.B, valueSize int, process func(any) ([]byte, error)) {
s := newStore() s := newStore()
b.StopTimer() b.StopTimer()
kvs, size := generateNRandomKV(b.N, valueSize) kvs, size := generateNRandomKV(b.N, valueSize)

View File

@ -45,13 +45,13 @@ func (h ttlKeyHeap) Swap(i, j int) {
h.keyMap[h.array[j]] = j h.keyMap[h.array[j]] = j
} }
func (h *ttlKeyHeap) Push(x interface{}) { func (h *ttlKeyHeap) Push(x any) {
n, _ := x.(*node) n, _ := x.(*node)
h.keyMap[n] = len(h.array) h.keyMap[n] = len(h.array)
h.array = append(h.array, n) h.array = append(h.array, n)
} }
func (h *ttlKeyHeap) Pop() interface{} { func (h *ttlKeyHeap) Pop() any {
old := h.array old := h.array
n := len(old) n := len(old)
x := old[n-1] x := old[n-1]
@ -77,7 +77,7 @@ func (h *ttlKeyHeap) pop() *node {
return n return n
} }
func (h *ttlKeyHeap) push(x interface{}) { func (h *ttlKeyHeap) push(x any) {
heap.Push(h, x) heap.Push(h, x)
} }

View File

@ -27,7 +27,7 @@ type fakeCompactable struct {
} }
func (fc *fakeCompactable) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) { func (fc *fakeCompactable) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
fc.Record(testutil.Action{Name: "c", Params: []interface{}{r}}) fc.Record(testutil.Action{Name: "c", Params: []any{r}})
return &pb.CompactionResponse{}, nil return &pb.CompactionResponse{}, nil
} }

View File

@ -18,13 +18,13 @@ import "github.com/golang/protobuf/proto"
type codec struct{} type codec struct{}
func (c *codec) Marshal(v interface{}) ([]byte, error) { func (c *codec) Marshal(v any) ([]byte, error) {
b, err := proto.Marshal(v.(proto.Message)) b, err := proto.Marshal(v.(proto.Message))
sentBytes.Add(float64(len(b))) sentBytes.Add(float64(len(b)))
return b, err return b, err
} }
func (c *codec) Unmarshal(data []byte, v interface{}) error { func (c *codec) Unmarshal(data []byte, v any) error {
receivedBytes.Add(float64(len(data))) receivedBytes.Add(float64(len(data)))
return proto.Unmarshal(data, v.(proto.Message)) return proto.Unmarshal(data, v.(proto.Message))
} }

View File

@ -45,7 +45,7 @@ type streamsMap struct {
} }
func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor { func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
if !api.IsCapabilityEnabled(api.V3rpcCapability) { if !api.IsCapabilityEnabled(api.V3rpcCapability) {
return nil, rpctypes.ErrGRPCNotCapable return nil, rpctypes.ErrGRPCNotCapable
} }
@ -77,7 +77,7 @@ func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
} }
func newLogUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor { func newLogUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
startTime := time.Now() startTime := time.Now()
resp, err := handler(ctx, req) resp, err := handler(ctx, req)
lg := s.Logger() lg := s.Logger()
@ -88,7 +88,7 @@ func newLogUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerIntercepto
} }
} }
func logUnaryRequestStats(ctx context.Context, lg *zap.Logger, warnLatency time.Duration, info *grpc.UnaryServerInfo, startTime time.Time, req interface{}, resp interface{}) { func logUnaryRequestStats(ctx context.Context, lg *zap.Logger, warnLatency time.Duration, info *grpc.UnaryServerInfo, startTime time.Time, req any, resp any) {
duration := time.Since(startTime) duration := time.Since(startTime)
var enabledDebugLevel, expensiveRequest bool var enabledDebugLevel, expensiveRequest bool
if lg.Core().Enabled(zap.DebugLevel) { if lg.Core().Enabled(zap.DebugLevel) {
@ -214,7 +214,7 @@ func logExpensiveRequestStats(lg *zap.Logger, startTime time.Time, duration time
func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor { func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor {
smap := monitorLeader(s) smap := monitorLeader(s)
return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
if !api.IsCapabilityEnabled(api.V3rpcCapability) { if !api.IsCapabilityEnabled(api.V3rpcCapability) {
return rpctypes.ErrGRPCNotCapable return rpctypes.ErrGRPCNotCapable
} }

View File

@ -37,7 +37,7 @@ type quotaAlarmer struct {
// check whether request satisfies the quota. If there is not enough space, // check whether request satisfies the quota. If there is not enough space,
// ignore request and raise the free space alarm. // ignore request and raise the free space alarm.
func (qa *quotaAlarmer) check(ctx context.Context, r interface{}) error { func (qa *quotaAlarmer) check(ctx context.Context, r any) error {
if qa.q.Available(r) { if qa.q.Available(r) {
return nil return nil
} }

View File

@ -138,7 +138,7 @@ func isClientCtxErr(ctxErr error, err error) bool {
} }
// in v3.4, learner is allowed to serve serializable read and endpoint status // in v3.4, learner is allowed to serve serializable read and endpoint status
func isRPCSupportedForLearner(req interface{}) bool { func isRPCSupportedForLearner(req any) bool {
switch r := req.(type) { switch r := req.(type) {
case *pb.StatusRequest: case *pb.StatusRequest:
return true return true

View File

@ -53,7 +53,7 @@ var (
) )
func init() { func init() {
expvar.Publish("raft.status", expvar.Func(func() interface{} { expvar.Publish("raft.status", expvar.Func(func() any {
raftStatusMu.Lock() raftStatusMu.Lock()
defer raftStatusMu.Unlock() defer raftStatusMu.Unlock()
if raftStatus == nil { if raftStatus == nil {

View File

@ -122,7 +122,7 @@ func init() {
expvar.Publish( expvar.Publish(
"file_descriptor_limit", "file_descriptor_limit",
expvar.Func( expvar.Func(
func() interface{} { func() any {
n, _ := runtime.FDLimit() n, _ := runtime.FDLimit()
return n return n
}, },

View File

@ -83,7 +83,7 @@ func TestDoLocalAction(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Get", Name: "Get",
Params: []interface{}{"", false, false}, Params: []any{"", false, false},
}, },
}, },
}, },
@ -93,7 +93,7 @@ func TestDoLocalAction(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Get", Name: "Get",
Params: []interface{}{"", false, false}, Params: []any{"", false, false},
}, },
}, },
}, },
@ -143,7 +143,7 @@ func TestDoBadLocalAction(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Get", Name: "Get",
Params: []interface{}{"", false, false}, Params: []any{"", false, false},
}, },
}, },
}, },
@ -152,7 +152,7 @@ func TestDoBadLocalAction(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Get", Name: "Get",
Params: []interface{}{"", false, false}, Params: []any{"", false, false},
}, },
}, },
}, },
@ -261,7 +261,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -272,7 +272,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Unix(0, 1337)}}, Params: []any{"", false, "", true, v2store.TTLOptionSet{ExpireTime: time.Unix(0, 1337)}},
}, },
}, },
}, },
@ -283,7 +283,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{"", true, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", true, "", true, v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -294,7 +294,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Set", Name: "Set",
Params: []interface{}{"", false, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", false, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -305,7 +305,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Set", Name: "Set",
Params: []interface{}{"", true, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", true, "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -316,7 +316,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Update", Name: "Update",
Params: []interface{}{"", "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -327,7 +327,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -338,7 +338,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndSwap", Name: "CompareAndSwap",
Params: []interface{}{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -349,7 +349,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Create", Name: "Create",
Params: []interface{}{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", false, "", false, v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -360,7 +360,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndSwap", Name: "CompareAndSwap",
Params: []interface{}{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", "", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -371,7 +371,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndSwap", Name: "CompareAndSwap",
Params: []interface{}{"", "bar", uint64(0), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", "bar", uint64(0), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -382,7 +382,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndSwap", Name: "CompareAndSwap",
Params: []interface{}{"", "bar", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}}, Params: []any{"", "bar", uint64(1), "", v2store.TTLOptionSet{ExpireTime: time.Time{}}},
}, },
}, },
}, },
@ -393,7 +393,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Delete", Name: "Delete",
Params: []interface{}{"", false, false}, Params: []any{"", false, false},
}, },
}, },
}, },
@ -404,7 +404,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndDelete", Name: "CompareAndDelete",
Params: []interface{}{"", "", uint64(1)}, Params: []any{"", "", uint64(1)},
}, },
}, },
}, },
@ -415,7 +415,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndDelete", Name: "CompareAndDelete",
Params: []interface{}{"", "bar", uint64(0)}, Params: []any{"", "bar", uint64(0)},
}, },
}, },
}, },
@ -426,7 +426,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "CompareAndDelete", Name: "CompareAndDelete",
Params: []interface{}{"", "bar", uint64(5)}, Params: []any{"", "bar", uint64(5)},
}, },
}, },
}, },
@ -437,7 +437,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "Get", Name: "Get",
Params: []interface{}{"", false, false}, Params: []any{"", false, false},
}, },
}, },
}, },
@ -448,7 +448,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "DeleteExpiredKeys", Name: "DeleteExpiredKeys",
Params: []interface{}{time.Unix(0, 0)}, Params: []any{time.Unix(0, 0)},
}, },
}, },
}, },
@ -458,7 +458,7 @@ func TestApplyRequest(t *testing.T) {
[]testutil.Action{ []testutil.Action{
{ {
Name: "DeleteExpiredKeys", Name: "DeleteExpiredKeys",
Params: []interface{}{time.Unix(0, 12345)}, Params: []any{time.Unix(0, 12345)},
}, },
}, },
}, },
@ -592,7 +592,7 @@ func TestApplyConfChangeError(t *testing.T) {
w := []testutil.Action{ w := []testutil.Action{
{ {
Name: "ApplyConfChange", Name: "ApplyConfChange",
Params: []interface{}{cc}, Params: []any{cc},
}, },
} }
if g, _ := n.Wait(1); !reflect.DeepEqual(g, w) { if g, _ := n.Wait(1); !reflect.DeepEqual(g, w) {
@ -1479,7 +1479,7 @@ func TestUpdateMember(t *testing.T) {
func TestPublishV3(t *testing.T) { func TestPublishV3(t *testing.T) {
n := newNodeRecorder() n := newNodeRecorder()
ch := make(chan interface{}, 1) ch := make(chan any, 1)
// simulate that request has gone through consensus // simulate that request has gone through consensus
ch <- &apply2.Result{} ch <- &apply2.Result{}
w := wait.NewWithResponse(ch) w := wait.NewWithResponse(ch)
@ -1600,7 +1600,7 @@ func TestPublishV3Retry(t *testing.T) {
func TestUpdateVersion(t *testing.T) { func TestUpdateVersion(t *testing.T) {
n := newNodeRecorder() n := newNodeRecorder()
ch := make(chan interface{}, 1) ch := make(chan any, 1)
// simulate that request has gone through consensus // simulate that request has gone through consensus
ch <- Response{} ch <- Response{}
w := wait.NewWithResponse(ch) w := wait.NewWithResponse(ch)
@ -1647,7 +1647,7 @@ func TestUpdateVersion(t *testing.T) {
func TestUpdateVersionV3(t *testing.T) { func TestUpdateVersionV3(t *testing.T) {
n := newNodeRecorder() n := newNodeRecorder()
ch := make(chan interface{}, 1) ch := make(chan any, 1)
// simulate that request has gone through consensus // simulate that request has gone through consensus
ch <- &apply2.Result{} ch <- &apply2.Result{}
w := wait.NewWithResponse(ch) w := wait.NewWithResponse(ch)
@ -1766,7 +1766,7 @@ func (n *nodeRecorder) Campaign(ctx context.Context) error {
return nil return nil
} }
func (n *nodeRecorder) Propose(ctx context.Context, data []byte) error { func (n *nodeRecorder) Propose(ctx context.Context, data []byte) error {
n.Record(testutil.Action{Name: "Propose", Params: []interface{}{data}}) n.Record(testutil.Action{Name: "Propose", Params: []any{data}})
return nil return nil
} }
func (n *nodeRecorder) ProposeConfChange(ctx context.Context, conf raftpb.ConfChangeI) error { func (n *nodeRecorder) ProposeConfChange(ctx context.Context, conf raftpb.ConfChangeI) error {
@ -1783,7 +1783,7 @@ func (n *nodeRecorder) TransferLeadership(ctx context.Context, lead, transferee
func (n *nodeRecorder) ReadIndex(ctx context.Context, rctx []byte) error { return nil } func (n *nodeRecorder) ReadIndex(ctx context.Context, rctx []byte) error { return nil }
func (n *nodeRecorder) Advance() {} func (n *nodeRecorder) Advance() {}
func (n *nodeRecorder) ApplyConfChange(conf raftpb.ConfChangeI) *raftpb.ConfState { func (n *nodeRecorder) ApplyConfChange(conf raftpb.ConfChangeI) *raftpb.ConfState {
n.Record(testutil.Action{Name: "ApplyConfChange", Params: []interface{}{conf}}) n.Record(testutil.Action{Name: "ApplyConfChange", Params: []any{conf}})
return &raftpb.ConfState{} return &raftpb.ConfState{}
} }

View File

@ -80,7 +80,7 @@ func TestMustDetectDowngrade(t *testing.T) {
} }
} }
func tryMustDetectDowngrade(lg *zap.Logger, sv, cv *semver.Version) (err interface{}) { func tryMustDetectDowngrade(lg *zap.Logger, sv, cv *semver.Version) (err any) {
defer func() { defer func() {
err = recover() err = recover()
}() }()

View File

@ -54,50 +54,50 @@ type zapRaftLogger struct {
sugar *zap.SugaredLogger sugar *zap.SugaredLogger
} }
func (zl *zapRaftLogger) Debug(args ...interface{}) { func (zl *zapRaftLogger) Debug(args ...any) {
zl.sugar.Debug(args...) zl.sugar.Debug(args...)
} }
func (zl *zapRaftLogger) Debugf(format string, args ...interface{}) { func (zl *zapRaftLogger) Debugf(format string, args ...any) {
zl.sugar.Debugf(format, args...) zl.sugar.Debugf(format, args...)
} }
func (zl *zapRaftLogger) Error(args ...interface{}) { func (zl *zapRaftLogger) Error(args ...any) {
zl.sugar.Error(args...) zl.sugar.Error(args...)
} }
func (zl *zapRaftLogger) Errorf(format string, args ...interface{}) { func (zl *zapRaftLogger) Errorf(format string, args ...any) {
zl.sugar.Errorf(format, args...) zl.sugar.Errorf(format, args...)
} }
func (zl *zapRaftLogger) Info(args ...interface{}) { func (zl *zapRaftLogger) Info(args ...any) {
zl.sugar.Info(args...) zl.sugar.Info(args...)
} }
func (zl *zapRaftLogger) Infof(format string, args ...interface{}) { func (zl *zapRaftLogger) Infof(format string, args ...any) {
zl.sugar.Infof(format, args...) zl.sugar.Infof(format, args...)
} }
func (zl *zapRaftLogger) Warning(args ...interface{}) { func (zl *zapRaftLogger) Warning(args ...any) {
zl.sugar.Warn(args...) zl.sugar.Warn(args...)
} }
func (zl *zapRaftLogger) Warningf(format string, args ...interface{}) { func (zl *zapRaftLogger) Warningf(format string, args ...any) {
zl.sugar.Warnf(format, args...) zl.sugar.Warnf(format, args...)
} }
func (zl *zapRaftLogger) Fatal(args ...interface{}) { func (zl *zapRaftLogger) Fatal(args ...any) {
zl.sugar.Fatal(args...) zl.sugar.Fatal(args...)
} }
func (zl *zapRaftLogger) Fatalf(format string, args ...interface{}) { func (zl *zapRaftLogger) Fatalf(format string, args ...any) {
zl.sugar.Fatalf(format, args...) zl.sugar.Fatalf(format, args...)
} }
func (zl *zapRaftLogger) Panic(args ...interface{}) { func (zl *zapRaftLogger) Panic(args ...any) {
zl.sugar.Panic(args...) zl.sugar.Panic(args...)
} }
func (zl *zapRaftLogger) Panicf(format string, args ...interface{}) { func (zl *zapRaftLogger) Panicf(format string, args ...any) {
zl.sugar.Panicf(format, args...) zl.sugar.Panicf(format, args...)
} }

View File

@ -42,14 +42,14 @@ func (pq LeaseQueue) Swap(i, j int) {
pq[j].index = j pq[j].index = j
} }
func (pq *LeaseQueue) Push(x interface{}) { func (pq *LeaseQueue) Push(x any) {
n := len(*pq) n := len(*pq)
item := x.(*LeaseWithTime) item := x.(*LeaseWithTime)
item.index = n item.index = n
*pq = append(*pq, item) *pq = append(*pq, item)
} }
func (pq *LeaseQueue) Pop() interface{} { func (pq *LeaseQueue) Pop() any {
old := *pq old := *pq
n := len(old) n := len(old)
item := old[n-1] item := old[n-1]

View File

@ -50,49 +50,49 @@ func (s *storeRecorder) Index() uint64 { return 0 }
func (s *storeRecorder) Get(path string, recursive, sorted bool) (*v2store.Event, error) { func (s *storeRecorder) Get(path string, recursive, sorted bool) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "Get", Name: "Get",
Params: []interface{}{path, recursive, sorted}, Params: []any{path, recursive, sorted},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
func (s *storeRecorder) Set(path string, dir bool, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { func (s *storeRecorder) Set(path string, dir bool, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "Set", Name: "Set",
Params: []interface{}{path, dir, val, expireOpts}, Params: []any{path, dir, val, expireOpts},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
func (s *storeRecorder) Update(path, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { func (s *storeRecorder) Update(path, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "Update", Name: "Update",
Params: []interface{}{path, val, expireOpts}, Params: []any{path, val, expireOpts},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
func (s *storeRecorder) Create(path string, dir bool, val string, uniq bool, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { func (s *storeRecorder) Create(path string, dir bool, val string, uniq bool, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "Create", Name: "Create",
Params: []interface{}{path, dir, val, uniq, expireOpts}, Params: []any{path, dir, val, uniq, expireOpts},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
func (s *storeRecorder) CompareAndSwap(path, prevVal string, prevIdx uint64, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) { func (s *storeRecorder) CompareAndSwap(path, prevVal string, prevIdx uint64, val string, expireOpts v2store.TTLOptionSet) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "CompareAndSwap", Name: "CompareAndSwap",
Params: []interface{}{path, prevVal, prevIdx, val, expireOpts}, Params: []any{path, prevVal, prevIdx, val, expireOpts},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
func (s *storeRecorder) Delete(path string, dir, recursive bool) (*v2store.Event, error) { func (s *storeRecorder) Delete(path string, dir, recursive bool) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "Delete", Name: "Delete",
Params: []interface{}{path, dir, recursive}, Params: []any{path, dir, recursive},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
func (s *storeRecorder) CompareAndDelete(path, prevVal string, prevIdx uint64) (*v2store.Event, error) { func (s *storeRecorder) CompareAndDelete(path, prevVal string, prevIdx uint64) (*v2store.Event, error) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "CompareAndDelete", Name: "CompareAndDelete",
Params: []interface{}{path, prevVal, prevIdx}, Params: []any{path, prevVal, prevIdx},
}) })
return &v2store.Event{}, nil return &v2store.Event{}, nil
} }
@ -123,7 +123,7 @@ func (s *storeRecorder) JsonStats() []byte { return nil }
func (s *storeRecorder) DeleteExpiredKeys(cutoff time.Time) { func (s *storeRecorder) DeleteExpiredKeys(cutoff time.Time) {
s.Record(testutil.Action{ s.Record(testutil.Action{
Name: "DeleteExpiredKeys", Name: "DeleteExpiredKeys",
Params: []interface{}{cutoff}, Params: []any{cutoff},
}) })
} }

View File

@ -34,11 +34,11 @@ func NewRecorder() *WaitRecorder {
} }
func NewNop() wait.Wait { return NewRecorder() } func NewNop() wait.Wait { return NewRecorder() }
func (w *waitRecorder) Register(id uint64) <-chan interface{} { func (w *waitRecorder) Register(id uint64) <-chan any {
w.Record(testutil.Action{Name: "Register"}) w.Record(testutil.Action{Name: "Register"})
return nil return nil
} }
func (w *waitRecorder) Trigger(id uint64, x interface{}) { func (w *waitRecorder) Trigger(id uint64, x any) {
w.Record(testutil.Action{Name: "Trigger"}) w.Record(testutil.Action{Name: "Trigger"})
} }

View File

@ -96,15 +96,15 @@ func (cs *chanClientStream) CloseSend() error {
// chanStream implements grpc.Stream using channels // chanStream implements grpc.Stream using channels
type chanStream struct { type chanStream struct {
recvc <-chan interface{} recvc <-chan any
sendc chan<- interface{} sendc chan<- any
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
} }
func (s *chanStream) Context() context.Context { return s.ctx } func (s *chanStream) Context() context.Context { return s.ctx }
func (s *chanStream) SendMsg(m interface{}) error { func (s *chanStream) SendMsg(m any) error {
select { select {
case s.sendc <- m: case s.sendc <- m:
if err, ok := m.(error); ok { if err, ok := m.(error); ok {
@ -116,8 +116,8 @@ func (s *chanStream) SendMsg(m interface{}) error {
return s.ctx.Err() return s.ctx.Err()
} }
func (s *chanStream) RecvMsg(m interface{}) error { func (s *chanStream) RecvMsg(m any) error {
v := m.(*interface{}) v := m.(*any)
for { for {
select { select {
case msg, ok := <-s.recvc: case msg, ok := <-s.recvc:
@ -141,7 +141,7 @@ func (s *chanStream) RecvMsg(m interface{}) error {
func newPipeStream(ctx context.Context, ssHandler func(chanServerStream) error) chanClientStream { func newPipeStream(ctx context.Context, ssHandler func(chanServerStream) error) chanClientStream {
// ch1 is buffered so server can send error on close // ch1 is buffered so server can send error on close
ch1, ch2 := make(chan interface{}, 1), make(chan interface{}) ch1, ch2 := make(chan any, 1), make(chan any)
headerc, trailerc := make(chan metadata.MD, 1), make(chan metadata.MD, 1) headerc, trailerc := make(chan metadata.MD, 1), make(chan metadata.MD, 1)
cctx, ccancel := context.WithCancel(ctx) cctx, ccancel := context.WithCancel(ctx)

View File

@ -61,7 +61,7 @@ func (s *es2ecClientStream) Send(rr *v3electionpb.LeaderRequest) error {
return s.SendMsg(rr) return s.SendMsg(rr)
} }
func (s *es2ecClientStream) Recv() (*v3electionpb.LeaderResponse, error) { func (s *es2ecClientStream) Recv() (*v3electionpb.LeaderResponse, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }
@ -72,7 +72,7 @@ func (s *es2ecServerStream) Send(rr *v3electionpb.LeaderResponse) error {
return s.SendMsg(rr) return s.SendMsg(rr)
} }
func (s *es2ecServerStream) Recv() (*v3electionpb.LeaderRequest, error) { func (s *es2ecServerStream) Recv() (*v3electionpb.LeaderRequest, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }

View File

@ -63,7 +63,7 @@ func (s *ls2lcClientStream) Send(rr *pb.LeaseKeepAliveRequest) error {
return s.SendMsg(rr) return s.SendMsg(rr)
} }
func (s *ls2lcClientStream) Recv() (*pb.LeaseKeepAliveResponse, error) { func (s *ls2lcClientStream) Recv() (*pb.LeaseKeepAliveResponse, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }
@ -74,7 +74,7 @@ func (s *ls2lcServerStream) Send(rr *pb.LeaseKeepAliveResponse) error {
return s.SendMsg(rr) return s.SendMsg(rr)
} }
func (s *ls2lcServerStream) Recv() (*pb.LeaseKeepAliveRequest, error) { func (s *ls2lcServerStream) Recv() (*pb.LeaseKeepAliveRequest, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }

View File

@ -73,7 +73,7 @@ func (s *ss2scClientStream) Send(rr *pb.SnapshotRequest) error {
return s.SendMsg(rr) return s.SendMsg(rr)
} }
func (s *ss2scClientStream) Recv() (*pb.SnapshotResponse, error) { func (s *ss2scClientStream) Recv() (*pb.SnapshotResponse, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }
@ -84,7 +84,7 @@ func (s *ss2scServerStream) Send(rr *pb.SnapshotResponse) error {
return s.SendMsg(rr) return s.SendMsg(rr)
} }
func (s *ss2scServerStream) Recv() (*pb.SnapshotRequest, error) { func (s *ss2scServerStream) Recv() (*pb.SnapshotRequest, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }

View File

@ -48,7 +48,7 @@ func (s *ws2wcClientStream) Send(wr *pb.WatchRequest) error {
return s.SendMsg(wr) return s.SendMsg(wr)
} }
func (s *ws2wcClientStream) Recv() (*pb.WatchResponse, error) { func (s *ws2wcClientStream) Recv() (*pb.WatchResponse, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }
@ -59,7 +59,7 @@ func (s *ws2wcServerStream) Send(wr *pb.WatchResponse) error {
return s.SendMsg(wr) return s.SendMsg(wr)
} }
func (s *ws2wcServerStream) Recv() (*pb.WatchRequest, error) { func (s *ws2wcServerStream) Recv() (*pb.WatchRequest, error) {
var v interface{} var v any
if err := s.RecvMsg(&v); err != nil { if err := s.RecvMsg(&v); err != nil {
return nil, err return nil, err
} }

View File

@ -56,7 +56,7 @@ func (cred *proxyTokenCredential) GetRequestMetadata(ctx context.Context, s ...s
}, nil }, nil
} }
func AuthUnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { func AuthUnaryClientInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
token := getAuthTokenFromClient(ctx) token := getAuthTokenFromClient(ctx)
if token != "" { if token != "" {
tokenCred := &proxyTokenCredential{token} tokenCred := &proxyTokenCredential{token}

View File

@ -91,7 +91,7 @@ func TestLockVerify(t *testing.T) {
} }
} }
func handlePanic(f func()) (result interface{}) { func handlePanic(f func()) (result any) {
defer func() { defer func() {
result = recover() result = recover()
}() }()

View File

@ -151,12 +151,12 @@ func TestStorePut(t *testing.T) {
} }
wact := []testutil.Action{ wact := []testutil.Action{
{Name: "seqput", Params: []interface{}{schema.Key, tt.wkey, data}}, {Name: "seqput", Params: []any{schema.Key, tt.wkey, data}},
} }
if tt.rr != nil { if tt.rr != nil {
wact = []testutil.Action{ wact = []testutil.Action{
{Name: "seqput", Params: []interface{}{schema.Key, tt.wkey, data}}, {Name: "seqput", Params: []any{schema.Key, tt.wkey, data}},
} }
} }
@ -164,8 +164,8 @@ func TestStorePut(t *testing.T) {
t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact) t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact)
} }
wact = []testutil.Action{ wact = []testutil.Action{
{Name: "get", Params: []interface{}{[]byte("foo"), tt.wputrev.main}}, {Name: "get", Params: []any{[]byte("foo"), tt.wputrev.main}},
{Name: "put", Params: []interface{}{[]byte("foo"), tt.wputrev}}, {Name: "put", Params: []any{[]byte("foo"), tt.wputrev}},
} }
if g := fi.Action(); !reflect.DeepEqual(g, wact) { if g := fi.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("#%d: index action = %+v, want %+v", i, g, wact) t.Errorf("#%d: index action = %+v, want %+v", i, g, wact)
@ -232,13 +232,13 @@ func TestStoreRange(t *testing.T) {
wstart := newRevBytes() wstart := newRevBytes()
revToBytes(tt.idxr.revs[0], wstart) revToBytes(tt.idxr.revs[0], wstart)
wact := []testutil.Action{ wact := []testutil.Action{
{Name: "range", Params: []interface{}{schema.Key, wstart, []byte(nil), int64(0)}}, {Name: "range", Params: []any{schema.Key, wstart, []byte(nil), int64(0)}},
} }
if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact) t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact)
} }
wact = []testutil.Action{ wact = []testutil.Action{
{Name: "range", Params: []interface{}{[]byte("foo"), []byte("goo"), wrev}}, {Name: "range", Params: []any{[]byte("foo"), []byte("goo"), wrev}},
} }
if g := fi.Action(); !reflect.DeepEqual(g, wact) { if g := fi.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("#%d: index action = %+v, want %+v", i, g, wact) t.Errorf("#%d: index action = %+v, want %+v", i, g, wact)
@ -308,14 +308,14 @@ func TestStoreDeleteRange(t *testing.T) {
t.Errorf("#%d: marshal err = %v, want nil", i, err) t.Errorf("#%d: marshal err = %v, want nil", i, err)
} }
wact := []testutil.Action{ wact := []testutil.Action{
{Name: "seqput", Params: []interface{}{schema.Key, tt.wkey, data}}, {Name: "seqput", Params: []any{schema.Key, tt.wkey, data}},
} }
if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact) t.Errorf("#%d: tx action = %+v, want %+v", i, g, wact)
} }
wact = []testutil.Action{ wact = []testutil.Action{
{Name: "range", Params: []interface{}{[]byte("foo"), []byte("goo"), tt.wrrev}}, {Name: "range", Params: []any{[]byte("foo"), []byte("goo"), tt.wrrev}},
{Name: "tombstone", Params: []interface{}{[]byte("foo"), tt.wdelrev}}, {Name: "tombstone", Params: []any{[]byte("foo"), tt.wdelrev}},
} }
if g := fi.Action(); !reflect.DeepEqual(g, wact) { if g := fi.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("#%d: index action = %+v, want %+v", i, g, wact) t.Errorf("#%d: index action = %+v, want %+v", i, g, wact)
@ -351,18 +351,18 @@ func TestStoreCompact(t *testing.T) {
end := make([]byte, 8) end := make([]byte, 8)
binary.BigEndian.PutUint64(end, uint64(4)) binary.BigEndian.PutUint64(end, uint64(4))
wact := []testutil.Action{ wact := []testutil.Action{
{Name: "range", Params: []interface{}{schema.Meta, schema.ScheduledCompactKeyName, []uint8(nil), int64(0)}}, {Name: "range", Params: []any{schema.Meta, schema.ScheduledCompactKeyName, []uint8(nil), int64(0)}},
{Name: "range", Params: []interface{}{schema.Meta, schema.FinishedCompactKeyName, []uint8(nil), int64(0)}}, {Name: "range", Params: []any{schema.Meta, schema.FinishedCompactKeyName, []uint8(nil), int64(0)}},
{Name: "put", Params: []interface{}{schema.Meta, schema.ScheduledCompactKeyName, newTestRevBytes(revision{3, 0})}}, {Name: "put", Params: []any{schema.Meta, schema.ScheduledCompactKeyName, newTestRevBytes(revision{3, 0})}},
{Name: "range", Params: []interface{}{schema.Key, make([]byte, 17), end, int64(10000)}}, {Name: "range", Params: []any{schema.Key, make([]byte, 17), end, int64(10000)}},
{Name: "delete", Params: []interface{}{schema.Key, key2}}, {Name: "delete", Params: []any{schema.Key, key2}},
{Name: "put", Params: []interface{}{schema.Meta, schema.FinishedCompactKeyName, newTestRevBytes(revision{3, 0})}}, {Name: "put", Params: []any{schema.Meta, schema.FinishedCompactKeyName, newTestRevBytes(revision{3, 0})}},
} }
if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("tx actions = %+v, want %+v", g, wact) t.Errorf("tx actions = %+v, want %+v", g, wact)
} }
wact = []testutil.Action{ wact = []testutil.Action{
{Name: "compact", Params: []interface{}{int64(3)}}, {Name: "compact", Params: []any{int64(3)}},
} }
if g := fi.Action(); !reflect.DeepEqual(g, wact) { if g := fi.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("index action = %+v, want %+v", g, wact) t.Errorf("index action = %+v, want %+v", g, wact)
@ -411,9 +411,9 @@ func TestStoreRestore(t *testing.T) {
t.Errorf("current rev = %v, want 5", s.currentRev) t.Errorf("current rev = %v, want 5", s.currentRev)
} }
wact := []testutil.Action{ wact := []testutil.Action{
{Name: "range", Params: []interface{}{schema.Meta, schema.FinishedCompactKeyName, []byte(nil), int64(0)}}, {Name: "range", Params: []any{schema.Meta, schema.FinishedCompactKeyName, []byte(nil), int64(0)}},
{Name: "range", Params: []interface{}{schema.Meta, schema.ScheduledCompactKeyName, []byte(nil), int64(0)}}, {Name: "range", Params: []any{schema.Meta, schema.ScheduledCompactKeyName, []byte(nil), int64(0)}},
{Name: "range", Params: []interface{}{schema.Key, newTestRevBytes(revision{1, 0}), newTestRevBytes(revision{math.MaxInt64, math.MaxInt64}), int64(restoreChunkKeys)}}, {Name: "range", Params: []any{schema.Key, newTestRevBytes(revision{1, 0}), newTestRevBytes(revision{math.MaxInt64, math.MaxInt64}), int64(restoreChunkKeys)}},
} }
if g := b.tx.Action(); !reflect.DeepEqual(g, wact) { if g := b.tx.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("tx actions = %+v, want %+v", g, wact) t.Errorf("tx actions = %+v, want %+v", g, wact)
@ -425,8 +425,8 @@ func TestStoreRestore(t *testing.T) {
} }
ki := &keyIndex{key: []byte("foo"), modified: revision{5, 0}, generations: gens} ki := &keyIndex{key: []byte("foo"), modified: revision{5, 0}, generations: gens}
wact = []testutil.Action{ wact = []testutil.Action{
{Name: "keyIndex", Params: []interface{}{ki}}, {Name: "keyIndex", Params: []any{ki}},
{Name: "insert", Params: []interface{}{ki}}, {Name: "insert", Params: []any{ki}},
} }
if g := fi.Action(); !reflect.DeepEqual(g, wact) { if g := fi.Action(); !reflect.DeepEqual(g, wact) {
t.Errorf("index action = %+v, want %+v", g, wact) t.Errorf("index action = %+v, want %+v", g, wact)
@ -950,18 +950,18 @@ func (b *fakeBatchTx) RUnlock() {}
func (b *fakeBatchTx) UnsafeCreateBucket(bucket backend.Bucket) {} func (b *fakeBatchTx) UnsafeCreateBucket(bucket backend.Bucket) {}
func (b *fakeBatchTx) UnsafeDeleteBucket(bucket backend.Bucket) {} func (b *fakeBatchTx) UnsafeDeleteBucket(bucket backend.Bucket) {}
func (b *fakeBatchTx) UnsafePut(bucket backend.Bucket, key []byte, value []byte) { func (b *fakeBatchTx) UnsafePut(bucket backend.Bucket, key []byte, value []byte) {
b.Recorder.Record(testutil.Action{Name: "put", Params: []interface{}{bucket, key, value}}) b.Recorder.Record(testutil.Action{Name: "put", Params: []any{bucket, key, value}})
} }
func (b *fakeBatchTx) UnsafeSeqPut(bucket backend.Bucket, key []byte, value []byte) { func (b *fakeBatchTx) UnsafeSeqPut(bucket backend.Bucket, key []byte, value []byte) {
b.Recorder.Record(testutil.Action{Name: "seqput", Params: []interface{}{bucket, key, value}}) b.Recorder.Record(testutil.Action{Name: "seqput", Params: []any{bucket, key, value}})
} }
func (b *fakeBatchTx) UnsafeRange(bucket backend.Bucket, key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte) { func (b *fakeBatchTx) UnsafeRange(bucket backend.Bucket, key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte) {
b.Recorder.Record(testutil.Action{Name: "range", Params: []interface{}{bucket, key, endKey, limit}}) b.Recorder.Record(testutil.Action{Name: "range", Params: []any{bucket, key, endKey, limit}})
r := <-b.rangeRespc r := <-b.rangeRespc
return r.keys, r.vals return r.keys, r.vals
} }
func (b *fakeBatchTx) UnsafeDelete(bucket backend.Bucket, key []byte) { func (b *fakeBatchTx) UnsafeDelete(bucket backend.Bucket, key []byte) {
b.Recorder.Record(testutil.Action{Name: "delete", Params: []interface{}{bucket, key}}) b.Recorder.Record(testutil.Action{Name: "delete", Params: []any{bucket, key}})
} }
func (b *fakeBatchTx) UnsafeForEach(bucket backend.Bucket, visitor func(k, v []byte) error) error { func (b *fakeBatchTx) UnsafeForEach(bucket backend.Bucket, visitor func(k, v []byte) error) error {
return nil return nil
@ -1024,43 +1024,43 @@ func (i *fakeIndex) CountRevisions(key, end []byte, atRev int64) int {
} }
func (i *fakeIndex) Get(key []byte, atRev int64) (rev, created revision, ver int64, err error) { func (i *fakeIndex) Get(key []byte, atRev int64) (rev, created revision, ver int64, err error) {
i.Recorder.Record(testutil.Action{Name: "get", Params: []interface{}{key, atRev}}) i.Recorder.Record(testutil.Action{Name: "get", Params: []any{key, atRev}})
r := <-i.indexGetRespc r := <-i.indexGetRespc
return r.rev, r.created, r.ver, r.err return r.rev, r.created, r.ver, r.err
} }
func (i *fakeIndex) Range(key, end []byte, atRev int64) ([][]byte, []revision) { func (i *fakeIndex) Range(key, end []byte, atRev int64) ([][]byte, []revision) {
i.Recorder.Record(testutil.Action{Name: "range", Params: []interface{}{key, end, atRev}}) i.Recorder.Record(testutil.Action{Name: "range", Params: []any{key, end, atRev}})
r := <-i.indexRangeRespc r := <-i.indexRangeRespc
return r.keys, r.revs return r.keys, r.revs
} }
func (i *fakeIndex) Put(key []byte, rev revision) { func (i *fakeIndex) Put(key []byte, rev revision) {
i.Recorder.Record(testutil.Action{Name: "put", Params: []interface{}{key, rev}}) i.Recorder.Record(testutil.Action{Name: "put", Params: []any{key, rev}})
} }
func (i *fakeIndex) Tombstone(key []byte, rev revision) error { func (i *fakeIndex) Tombstone(key []byte, rev revision) error {
i.Recorder.Record(testutil.Action{Name: "tombstone", Params: []interface{}{key, rev}}) i.Recorder.Record(testutil.Action{Name: "tombstone", Params: []any{key, rev}})
return nil return nil
} }
func (i *fakeIndex) RangeSince(key, end []byte, rev int64) []revision { func (i *fakeIndex) RangeSince(key, end []byte, rev int64) []revision {
i.Recorder.Record(testutil.Action{Name: "rangeEvents", Params: []interface{}{key, end, rev}}) i.Recorder.Record(testutil.Action{Name: "rangeEvents", Params: []any{key, end, rev}})
r := <-i.indexRangeEventsRespc r := <-i.indexRangeEventsRespc
return r.revs return r.revs
} }
func (i *fakeIndex) Compact(rev int64) map[revision]struct{} { func (i *fakeIndex) Compact(rev int64) map[revision]struct{} {
i.Recorder.Record(testutil.Action{Name: "compact", Params: []interface{}{rev}}) i.Recorder.Record(testutil.Action{Name: "compact", Params: []any{rev}})
return <-i.indexCompactRespc return <-i.indexCompactRespc
} }
func (i *fakeIndex) Keep(rev int64) map[revision]struct{} { func (i *fakeIndex) Keep(rev int64) map[revision]struct{} {
i.Recorder.Record(testutil.Action{Name: "keep", Params: []interface{}{rev}}) i.Recorder.Record(testutil.Action{Name: "keep", Params: []any{rev}})
return <-i.indexCompactRespc return <-i.indexCompactRespc
} }
func (i *fakeIndex) Equal(b index) bool { return false } func (i *fakeIndex) Equal(b index) bool { return false }
func (i *fakeIndex) Insert(ki *keyIndex) { func (i *fakeIndex) Insert(ki *keyIndex) {
i.Recorder.Record(testutil.Action{Name: "insert", Params: []interface{}{ki}}) i.Recorder.Record(testutil.Action{Name: "insert", Params: []any{ki}})
} }
func (i *fakeIndex) KeyIndex(ki *keyIndex) *keyIndex { func (i *fakeIndex) KeyIndex(ki *keyIndex) *keyIndex {
i.Recorder.Record(testutil.Action{Name: "keyIndex", Params: []interface{}{ki}}) i.Recorder.Record(testutil.Action{Name: "keyIndex", Params: []any{ki}})
return nil return nil
} }

View File

@ -38,18 +38,18 @@ const (
// too few resources available within the quota to apply the request. // too few resources available within the quota to apply the request.
type Quota interface { type Quota interface {
// Available judges whether the given request fits within the quota. // Available judges whether the given request fits within the quota.
Available(req interface{}) bool Available(req any) bool
// Cost computes the charge against the quota for a given request. // Cost computes the charge against the quota for a given request.
Cost(req interface{}) int Cost(req any) int
// Remaining is the amount of charge left for the quota. // Remaining is the amount of charge left for the quota.
Remaining() int64 Remaining() int64
} }
type passthroughQuota struct{} type passthroughQuota struct{}
func (*passthroughQuota) Available(interface{}) bool { return true } func (*passthroughQuota) Available(any) bool { return true }
func (*passthroughQuota) Cost(interface{}) int { return 0 } func (*passthroughQuota) Cost(any) int { return 0 }
func (*passthroughQuota) Remaining() int64 { return 1 } func (*passthroughQuota) Remaining() int64 { return 1 }
type BackendQuota struct { type BackendQuota struct {
be backend.Backend be backend.Backend
@ -123,7 +123,7 @@ func NewBackendQuota(lg *zap.Logger, quotaBackendBytesCfg int64, be backend.Back
return &BackendQuota{be, quotaBackendBytesCfg} return &BackendQuota{be, quotaBackendBytesCfg}
} }
func (b *BackendQuota) Available(v interface{}) bool { func (b *BackendQuota) Available(v any) bool {
cost := b.Cost(v) cost := b.Cost(v)
// if there are no mutating requests, it's safe to pass through // if there are no mutating requests, it's safe to pass through
if cost == 0 { if cost == 0 {
@ -133,7 +133,7 @@ func (b *BackendQuota) Available(v interface{}) bool {
return b.be.Size()+int64(cost) < b.maxBackendBytes return b.be.Size()+int64(cost) < b.maxBackendBytes
} }
func (b *BackendQuota) Cost(v interface{}) int { func (b *BackendQuota) Cost(v any) int {
switch r := v.(type) { switch r := v.(type) {
case *pb.PutRequest: case *pb.PutRequest:
return costPut(r) return costPut(r)

View File

@ -216,6 +216,6 @@ func fetchDebugVars(endpoint string, httpVersion string, connType e2e.ClientConn
if err != nil { if err != nil {
return err return err
} }
var resp map[string]interface{} var resp map[string]any
return json.Unmarshal([]byte(respData), &resp) return json.Unmarshal([]byte(respData), &resp)
} }

View File

@ -110,13 +110,13 @@ func curl(endpoint string, method string, curlReq e2e.CURLReq, connType e2e.Clie
return strings.Join(lines, "\n"), nil return strings.Join(lines, "\n"), nil
} }
func runCommandAndReadJsonOutput(args []string) (map[string]interface{}, error) { func runCommandAndReadJsonOutput(args []string) (map[string]any, error) {
lines, err := e2e.RunUtilCompletion(args, nil) lines, err := e2e.RunUtilCompletion(args, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var resp map[string]interface{} var resp map[string]any
err = json.Unmarshal([]byte(strings.Join(lines, "\n")), &resp) err = json.Unmarshal([]byte(strings.Join(lines, "\n")), &resp)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -147,7 +147,7 @@ func testCurlV3Auth(cx ctlCtx) {
cURLRes, err := proc.ExpectFunc(context.Background(), lineFunc) cURLRes, err := proc.ExpectFunc(context.Background(), lineFunc)
testutil.AssertNil(cx.t, err) testutil.AssertNil(cx.t, err)
authRes := make(map[string]interface{}) authRes := make(map[string]any)
testutil.AssertNil(cx.t, json.Unmarshal([]byte(cURLRes), &authRes)) testutil.AssertNil(cx.t, json.Unmarshal([]byte(cURLRes), &authRes))
token, ok := authRes[rpctypes.TokenFieldNameGRPC].(string) token, ok := authRes[rpctypes.TokenFieldNameGRPC].(string)
@ -241,7 +241,7 @@ func testCurlV3AuthUserBasicOperations(cx ctlCtx) {
users, ok := resp["users"] users, ok := resp["users"]
require.True(cx.t, ok) require.True(cx.t, ok)
userSlice := users.([]interface{}) userSlice := users.([]any)
require.Equal(cx.t, 2, len(userSlice)) require.Equal(cx.t, 2, len(userSlice))
require.Equal(cx.t, "user1", userSlice[0]) require.Equal(cx.t, "user1", userSlice[0])
require.Equal(cx.t, "user3", userSlice[1]) require.Equal(cx.t, "user3", userSlice[1])
@ -370,7 +370,7 @@ func testCurlV3AuthRoleBasicOperations(cx ctlCtx) {
roles, ok := resp["roles"] roles, ok := resp["roles"]
require.True(cx.t, ok) require.True(cx.t, ok)
roleSlice := roles.([]interface{}) roleSlice := roles.([]any)
require.Equal(cx.t, 2, len(roleSlice)) require.Equal(cx.t, 2, len(roleSlice))
require.Equal(cx.t, "role1", roleSlice[0]) require.Equal(cx.t, "role1", roleSlice[0])
require.Equal(cx.t, "role3", roleSlice[1]) require.Equal(cx.t, "role3", roleSlice[1])

View File

@ -58,9 +58,9 @@ func testCurlV3ClusterOperations(cx ctlCtx) {
var newMemberIDStr string var newMemberIDStr string
for _, m := range members { for _, m := range members {
mObj := m.(map[string]interface{}) mObj := m.(map[string]any)
pURLs, _ := mObj["peerURLs"] pURLs, _ := mObj["peerURLs"]
pURL := pURLs.([]interface{})[0].(string) pURL := pURLs.([]any)[0].(string)
if pURL == peerURL { if pURL == peerURL {
newMemberIDStr = mObj["ID"].(string) newMemberIDStr = mObj["ID"].(string)
break break
@ -108,7 +108,7 @@ func testCurlV3ClusterOperations(cx ctlCtx) {
require.Equal(cx.t, 1, len(members)) require.Equal(cx.t, 1, len(members))
} }
func mustListMembers(cx ctlCtx) []interface{} { func mustListMembers(cx ctlCtx) []any {
clus := cx.epc clus := cx.epc
args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[0], "POST", e2e.CURLReq{ args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[0], "POST", e2e.CURLReq{
Endpoint: "/v3/cluster/member/list", Endpoint: "/v3/cluster/member/list",
@ -119,5 +119,5 @@ func mustListMembers(cx ctlCtx) []interface{} {
members, ok := resp["members"] members, ok := resp["members"]
require.True(cx.t, ok) require.True(cx.t, ok)
return members.([]interface{}) return members.([]any)
} }

View File

@ -158,7 +158,7 @@ func testCurlV3KVTxn(cx ctlCtx) {
succeeded, responses := mustExecuteTxn(cx, string(jsonDat)) succeeded, responses := mustExecuteTxn(cx, string(jsonDat))
require.True(cx.t, succeeded) require.True(cx.t, succeeded)
require.Equal(cx.t, 1, len(responses)) require.Equal(cx.t, 1, len(responses))
putResponse := responses[0].(map[string]interface{}) putResponse := responses[0].(map[string]any)
_, ok := putResponse["response_put"] _, ok := putResponse["response_put"]
require.True(cx.t, ok) require.True(cx.t, ok)
@ -172,7 +172,7 @@ func testCurlV3KVTxn(cx ctlCtx) {
require.NoErrorf(cx.t, err, "testCurlV3Txn with malformed request failed") require.NoErrorf(cx.t, err, "testCurlV3Txn with malformed request failed")
} }
func mustExecuteTxn(cx ctlCtx, reqData string) (bool, []interface{}) { func mustExecuteTxn(cx ctlCtx, reqData string) (bool, []any) {
clus := cx.epc clus := cx.epc
args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[0], "POST", e2e.CURLReq{ args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[0], "POST", e2e.CURLReq{
Endpoint: "/v3/kv/txn", Endpoint: "/v3/kv/txn",
@ -187,7 +187,7 @@ func mustExecuteTxn(cx ctlCtx, reqData string) (bool, []interface{}) {
responses, ok := resp["responses"] responses, ok := resp["responses"]
require.True(cx.t, ok) require.True(cx.t, ok)
return succeeded.(bool), responses.([]interface{}) return succeeded.(bool), responses.([]any)
} }
func testCurlV3KVCompact(cx ctlCtx) { func testCurlV3KVCompact(cx ctlCtx) {

View File

@ -660,7 +660,7 @@ func (ctl *EtcdctlV3) RoleDelete(ctx context.Context, role string) (*clientv3.Au
return &resp, err return &resp, err
} }
func (ctl *EtcdctlV3) spawnJsonCmd(ctx context.Context, output interface{}, args ...string) error { func (ctl *EtcdctlV3) spawnJsonCmd(ctx context.Context, output any, args ...string) error {
args = append(args, "-w", "json") args = append(args, "-w", "json")
cmd, err := SpawnCmd(append(ctl.cmdArgs(), args...), nil) cmd, err := SpawnCmd(append(ctl.cmdArgs(), args...), nil)
if err != nil { if err != nil {

View File

@ -108,7 +108,7 @@ func RandomLeaseID() int64 {
return rand.New(rand.NewSource(time.Now().UnixNano())).Int63() return rand.New(rand.NewSource(time.Now().UnixNano())).Int63()
} }
func DataMarshal(data interface{}) (d string, e error) { func DataMarshal(data any) (d string, e error) {
m, err := json.Marshal(data) m, err := json.Marshal(data)
if err != nil { if err != nil {
return "", err return "", err

View File

@ -480,7 +480,7 @@ func TestV3AuthWatchErrorAndWatchId0(t *testing.T) {
} }
defer c.Close() defer c.Close()
watchStartCh, watchEndCh := make(chan interface{}), make(chan interface{}) watchStartCh, watchEndCh := make(chan any), make(chan any)
go func() { go func() {
wChan := c.Watch(ctx, "k1", clientv3.WithRev(1)) wChan := c.Watch(ctx, "k1", clientv3.WithRev(1))

View File

@ -38,14 +38,14 @@ import (
// to provide a full response. For example stale reads as model doesn't store // to provide a full response. For example stale reads as model doesn't store
// whole change history as real etcd does. // whole change history as real etcd does.
var DeterministicModel = porcupine.Model{ var DeterministicModel = porcupine.Model{
Init: func() interface{} { Init: func() any {
data, err := json.Marshal(freshEtcdState()) data, err := json.Marshal(freshEtcdState())
if err != nil { if err != nil {
panic(err) panic(err)
} }
return string(data) return string(data)
}, },
Step: func(st interface{}, in interface{}, out interface{}) (bool, interface{}) { Step: func(st any, in any, out any) (bool, any) {
var s EtcdState var s EtcdState
err := json.Unmarshal([]byte(st.(string)), &s) err := json.Unmarshal([]byte(st.(string)), &s)
if err != nil { if err != nil {
@ -58,7 +58,7 @@ var DeterministicModel = porcupine.Model{
} }
return ok, string(data) return ok, string(data)
}, },
DescribeOperation: func(in, out interface{}) string { DescribeOperation: func(in, out any) string {
return fmt.Sprintf("%s -> %s", describeEtcdRequest(in.(EtcdRequest)), describeEtcdResponse(in.(EtcdRequest), MaybeEtcdResponse{EtcdResponse: out.(EtcdResponse)})) return fmt.Sprintf("%s -> %s", describeEtcdRequest(in.(EtcdRequest)), describeEtcdResponse(in.(EtcdRequest), MaybeEtcdResponse{EtcdResponse: out.(EtcdResponse)}))
}, },
} }

View File

@ -27,14 +27,14 @@ import (
// considers both cases. This is represented as multiple equally possible deterministic states. // considers both cases. This is represented as multiple equally possible deterministic states.
// Failed requests fork the possible states, while successful requests merge and filter them. // Failed requests fork the possible states, while successful requests merge and filter them.
var NonDeterministicModel = porcupine.Model{ var NonDeterministicModel = porcupine.Model{
Init: func() interface{} { Init: func() any {
data, err := json.Marshal(nonDeterministicState{freshEtcdState()}) data, err := json.Marshal(nonDeterministicState{freshEtcdState()})
if err != nil { if err != nil {
panic(err) panic(err)
} }
return string(data) return string(data)
}, },
Step: func(st interface{}, in interface{}, out interface{}) (bool, interface{}) { Step: func(st any, in any, out any) (bool, any) {
var states nonDeterministicState var states nonDeterministicState
err := json.Unmarshal([]byte(st.(string)), &states) err := json.Unmarshal([]byte(st.(string)), &states)
if err != nil { if err != nil {
@ -47,7 +47,7 @@ var NonDeterministicModel = porcupine.Model{
} }
return ok, string(data) return ok, string(data)
}, },
DescribeOperation: func(in, out interface{}) string { DescribeOperation: func(in, out any) string {
return fmt.Sprintf("%s -> %s", describeEtcdRequest(in.(EtcdRequest)), describeEtcdResponse(in.(EtcdRequest), out.(MaybeEtcdResponse))) return fmt.Sprintf("%s -> %s", describeEtcdRequest(in.(EtcdRequest)), describeEtcdResponse(in.(EtcdRequest), out.(MaybeEtcdResponse)))
}, },
} }

View File

@ -74,12 +74,12 @@ func validateOrdered(t *testing.T, report report.ClientReport) {
} }
func validateUnique(t *testing.T, expectUniqueRevision bool, report report.ClientReport) { func validateUnique(t *testing.T, expectUniqueRevision bool, report report.ClientReport) {
uniqueOperations := map[interface{}]struct{}{} uniqueOperations := map[any]struct{}{}
for _, op := range report.Watch { for _, op := range report.Watch {
for _, resp := range op.Responses { for _, resp := range op.Responses {
for _, event := range resp.Events { for _, event := range resp.Events {
var key interface{} var key any
if expectUniqueRevision { if expectUniqueRevision {
key = event.Revision key = event.Revision
} else { } else {