chore: change interface{} to any (#2818)
* chore: change interface{} to any
* chore: update goctl version to 1.5.0
* chore: update goctl deps
This commit is contained in:
@@ -85,7 +85,7 @@ func TestDepositServer_Deposit(t *testing.T) {
|
||||
},
|
||||
},
|
||||
WithDialOption(grpc.WithContextDialer(dialer())),
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}),
|
||||
@@ -106,7 +106,7 @@ func TestDepositServer_Deposit(t *testing.T) {
|
||||
},
|
||||
},
|
||||
WithDialOption(grpc.WithContextDialer(dialer())),
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}),
|
||||
@@ -127,7 +127,7 @@ func TestDepositServer_Deposit(t *testing.T) {
|
||||
},
|
||||
WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
|
||||
WithDialOption(grpc.WithContextDialer(dialer())),
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}),
|
||||
@@ -135,7 +135,7 @@ func TestDepositServer_Deposit(t *testing.T) {
|
||||
targetClient, err := NewClientWithTarget("foo",
|
||||
WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
|
||||
WithDialOption(grpc.WithContextDialer(dialer())), WithUnaryClientInterceptor(
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}), WithTimeout(1000*time.Millisecond))
|
||||
@@ -188,7 +188,7 @@ func TestNewClientWithError(t *testing.T) {
|
||||
},
|
||||
WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
|
||||
WithDialOption(grpc.WithContextDialer(dialer())),
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}),
|
||||
@@ -207,7 +207,7 @@ func TestNewClientWithError(t *testing.T) {
|
||||
},
|
||||
WithDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
|
||||
WithDialOption(grpc.WithContextDialer(dialer())),
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||
WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}),
|
||||
|
||||
@@ -57,7 +57,7 @@ func (a *Authenticator) Authenticate(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (a *Authenticator) validate(app, token string) error {
|
||||
expect, err := a.cache.Take(app, func() (interface{}, error) {
|
||||
expect, err := a.cache.Take(app, func() (any, error) {
|
||||
return a.store.Hget(a.key, app)
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestP2cPicker_Pick(t *testing.T) {
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
dist := make(map[interface{}]int)
|
||||
dist := make(map[any]int)
|
||||
conns := picker.(*p2cPicker).conns
|
||||
for _, conn := range conns {
|
||||
dist[conn.addr.Addr] = int(conn.requests)
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestWithTransportCredentials(t *testing.T) {
|
||||
|
||||
func TestWithUnaryClientInterceptor(t *testing.T) {
|
||||
var options ClientOptions
|
||||
opt := WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply interface{},
|
||||
opt := WithUnaryClientInterceptor(func(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// BreakerInterceptor is an interceptor that acts as a circuit breaker.
|
||||
func BreakerInterceptor(ctx context.Context, method string, req, reply interface{},
|
||||
func BreakerInterceptor(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
breakerName := path.Join(cc.Target(), method)
|
||||
return breaker.DoWithAcceptable(breakerName, func() error {
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestBreakerInterceptor(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cc := new(grpc.ClientConn)
|
||||
err := BreakerInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
return test.err
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ var (
|
||||
)
|
||||
|
||||
// DurationInterceptor is an interceptor that logs the processing time.
|
||||
func DurationInterceptor(ctx context.Context, method string, req, reply interface{},
|
||||
func DurationInterceptor(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
serverName := path.Join(cc.Target(), method)
|
||||
start := timex.Now()
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestDurationInterceptor(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cc := new(grpc.ClientConn)
|
||||
err := DurationInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
return test.err
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ var (
|
||||
)
|
||||
|
||||
// PrometheusInterceptor is an interceptor that reports to prometheus server.
|
||||
func PrometheusInterceptor(ctx context.Context, method string, req, reply interface{},
|
||||
func PrometheusInterceptor(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
startTime := timex.Now()
|
||||
err := invoker(ctx, method, req, reply, cc, opts...)
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestPromMetricInterceptor(t *testing.T) {
|
||||
}
|
||||
cc := new(grpc.ClientConn)
|
||||
err := PrometheusInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
return test.err
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// TimeoutInterceptor is an interceptor that controls timeout.
|
||||
func TimeoutInterceptor(timeout time.Duration) grpc.UnaryClientInterceptor {
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
if timeout <= 0 {
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestTimeoutInterceptor(t *testing.T) {
|
||||
interceptor := TimeoutInterceptor(timeout)
|
||||
cc := new(grpc.ClientConn)
|
||||
err := interceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
return nil
|
||||
},
|
||||
@@ -37,7 +37,7 @@ func TestTimeoutInterceptor_timeout(t *testing.T) {
|
||||
wg.Add(1)
|
||||
cc := new(grpc.ClientConn)
|
||||
err := interceptor(ctx, "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
defer wg.Done()
|
||||
tm, ok := ctx.Deadline()
|
||||
@@ -57,7 +57,7 @@ func TestTimeoutInterceptor_panic(t *testing.T) {
|
||||
cc := new(grpc.ClientConn)
|
||||
assert.Panics(t, func() {
|
||||
_ = interceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
panic("any")
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ const (
|
||||
)
|
||||
|
||||
// UnaryTracingInterceptor returns a grpc.UnaryClientInterceptor for opentelemetry.
|
||||
func UnaryTracingInterceptor(ctx context.Context, method string, req, reply interface{},
|
||||
func UnaryTracingInterceptor(ctx context.Context, method string, req, reply any,
|
||||
cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
ctx, span := startSpan(ctx, method, cc.Target())
|
||||
defer span.End()
|
||||
@@ -118,7 +118,7 @@ func (w *clientStream) Header() (metadata.MD, error) {
|
||||
return md, err
|
||||
}
|
||||
|
||||
func (w *clientStream) RecvMsg(m interface{}) error {
|
||||
func (w *clientStream) RecvMsg(m any) error {
|
||||
err := w.ClientStream.RecvMsg(m)
|
||||
if err == nil && !w.desc.ServerStreams {
|
||||
w.sendStreamEvent(receiveEndEvent, nil)
|
||||
@@ -134,7 +134,7 @@ func (w *clientStream) RecvMsg(m interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *clientStream) SendMsg(m interface{}) error {
|
||||
func (w *clientStream) SendMsg(m any) error {
|
||||
err := w.ClientStream.SendMsg(m)
|
||||
w.sentMessageID++
|
||||
ztrace.MessageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestOpenTracingInterceptor(t *testing.T) {
|
||||
cc := new(grpc.ClientConn)
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), metadata.MD{})
|
||||
err := UnaryTracingInterceptor(ctx, "/ListUser", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
return nil
|
||||
})
|
||||
@@ -41,7 +41,7 @@ func TestUnaryTracingInterceptor(t *testing.T) {
|
||||
wg.Add(1)
|
||||
cc := new(grpc.ClientConn)
|
||||
err := UnaryTracingInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
defer wg.Done()
|
||||
atomic.AddInt32(&run, 1)
|
||||
@@ -58,7 +58,7 @@ func TestUnaryTracingInterceptor_WithError(t *testing.T) {
|
||||
wg.Add(1)
|
||||
cc := new(grpc.ClientConn)
|
||||
err := UnaryTracingInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
defer wg.Done()
|
||||
atomic.AddInt32(&run, 1)
|
||||
@@ -195,7 +195,7 @@ func TestUnaryTracingInterceptor_GrpcFormat(t *testing.T) {
|
||||
wg.Add(1)
|
||||
cc := new(grpc.ClientConn)
|
||||
err := UnaryTracingInterceptor(context.Background(), "/foo", nil, nil, cc,
|
||||
func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn,
|
||||
func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn,
|
||||
opts ...grpc.CallOption) error {
|
||||
defer wg.Done()
|
||||
atomic.AddInt32(&run, 1)
|
||||
@@ -339,10 +339,10 @@ func (m *mockedClientStream) Context() context.Context {
|
||||
return context.Background()
|
||||
}
|
||||
|
||||
func (m *mockedClientStream) SendMsg(v interface{}) error {
|
||||
func (m *mockedClientStream) SendMsg(v any) error {
|
||||
return m.err
|
||||
}
|
||||
|
||||
func (m *mockedClientStream) RecvMsg(v interface{}) error {
|
||||
func (m *mockedClientStream) RecvMsg(v any) error {
|
||||
return m.err
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func file_deposit_proto_rawDescGZIP() []byte {
|
||||
|
||||
var (
|
||||
file_deposit_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
file_deposit_proto_goTypes = []interface{}{
|
||||
file_deposit_proto_goTypes = []any{
|
||||
(*DepositRequest)(nil), // 0: mock.DepositRequest
|
||||
(*DepositResponse)(nil), // 1: mock.DepositResponse
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func file_deposit_proto_init() {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_deposit_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_deposit_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DepositRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -184,7 +184,7 @@ func file_deposit_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_deposit_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_deposit_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DepositResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -267,7 +267,7 @@ func RegisterDepositServiceServer(s *grpc.Server, srv DepositServiceServer) {
|
||||
s.RegisterService(&_DepositService_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _DepositService_Deposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _DepositService_Deposit_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(DepositRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
@@ -279,7 +279,7 @@ func _DepositService_Deposit_Handler(srv interface{}, ctx context.Context, dec f
|
||||
Server: srv,
|
||||
FullMethod: "/mock.DepositService/Deposit",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DepositServiceServer).Deposit(ctx, req.(*DepositRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
|
||||
@@ -16,47 +16,47 @@ func init() {
|
||||
}
|
||||
|
||||
// Error logs the given args into error log.
|
||||
func (l *Logger) Error(args ...interface{}) {
|
||||
func (l *Logger) Error(args ...any) {
|
||||
logx.Error(args...)
|
||||
}
|
||||
|
||||
// Errorf logs the given args with format into error log.
|
||||
func (l *Logger) Errorf(format string, args ...interface{}) {
|
||||
func (l *Logger) Errorf(format string, args ...any) {
|
||||
logx.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// Errorln logs the given args into error log with newline.
|
||||
func (l *Logger) Errorln(args ...interface{}) {
|
||||
func (l *Logger) Errorln(args ...any) {
|
||||
logx.Error(args...)
|
||||
}
|
||||
|
||||
// Fatal logs the given args into error log.
|
||||
func (l *Logger) Fatal(args ...interface{}) {
|
||||
func (l *Logger) Fatal(args ...any) {
|
||||
logx.Error(args...)
|
||||
}
|
||||
|
||||
// Fatalf logs the given args with format into error log.
|
||||
func (l *Logger) Fatalf(format string, args ...interface{}) {
|
||||
func (l *Logger) Fatalf(format string, args ...any) {
|
||||
logx.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// Fatalln logs args into error log with newline.
|
||||
func (l *Logger) Fatalln(args ...interface{}) {
|
||||
func (l *Logger) Fatalln(args ...any) {
|
||||
logx.Error(args...)
|
||||
}
|
||||
|
||||
// Info ignores the grpc info logs.
|
||||
func (l *Logger) Info(args ...interface{}) {
|
||||
func (l *Logger) Info(args ...any) {
|
||||
// ignore builtin grpc info
|
||||
}
|
||||
|
||||
// Infoln ignores the grpc info logs.
|
||||
func (l *Logger) Infoln(args ...interface{}) {
|
||||
func (l *Logger) Infoln(args ...any) {
|
||||
// ignore builtin grpc info
|
||||
}
|
||||
|
||||
// Infof ignores the grpc info logs.
|
||||
func (l *Logger) Infof(format string, args ...interface{}) {
|
||||
func (l *Logger) Infof(format string, args ...any) {
|
||||
// ignore builtin grpc info
|
||||
}
|
||||
|
||||
@@ -66,16 +66,16 @@ func (l *Logger) V(v int) bool {
|
||||
}
|
||||
|
||||
// Warning ignores the grpc warning logs.
|
||||
func (l *Logger) Warning(args ...interface{}) {
|
||||
func (l *Logger) Warning(args ...any) {
|
||||
// ignore builtin grpc warning
|
||||
}
|
||||
|
||||
// Warningf ignores the grpc warning logs.
|
||||
func (l *Logger) Warningf(format string, args ...interface{}) {
|
||||
func (l *Logger) Warningf(format string, args ...any) {
|
||||
// ignore builtin grpc warning
|
||||
}
|
||||
|
||||
// Warningln ignores the grpc warning logs.
|
||||
func (l *Logger) Warningln(args ...interface{}) {
|
||||
func (l *Logger) Warningln(args ...any) {
|
||||
// ignore builtin grpc warning
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestBaseRpcServer_AddStreamInterceptors(t *testing.T) {
|
||||
server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics})
|
||||
server.SetName("bar")
|
||||
var vals []int
|
||||
f := func(_ interface{}, _ grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error {
|
||||
f := func(_ any, _ grpc.ServerStream, _ *grpc.StreamServerInfo, _ grpc.StreamHandler) error {
|
||||
vals = append(vals, 1)
|
||||
return nil
|
||||
}
|
||||
@@ -39,8 +39,8 @@ func TestBaseRpcServer_AddUnaryInterceptors(t *testing.T) {
|
||||
server := newBaseRpcServer("foo", &rpcServerOptions{metrics: metrics})
|
||||
server.SetName("bar")
|
||||
var vals []int
|
||||
f := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
|
||||
resp interface{}, err error) {
|
||||
f := func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (
|
||||
resp any, err error) {
|
||||
vals = append(vals, 1)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// StreamAuthorizeInterceptor returns a func that uses given authenticator in processing stream requests.
|
||||
func StreamAuthorizeInterceptor(authenticator *auth.Authenticator) grpc.StreamServerInterceptor {
|
||||
return func(svr interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo,
|
||||
return func(svr any, stream grpc.ServerStream, info *grpc.StreamServerInfo,
|
||||
handler grpc.StreamHandler) error {
|
||||
if err := authenticator.Authenticate(stream.Context()); err != nil {
|
||||
return err
|
||||
@@ -21,8 +21,8 @@ func StreamAuthorizeInterceptor(authenticator *auth.Authenticator) grpc.StreamSe
|
||||
|
||||
// UnaryAuthorizeInterceptor returns a func that uses given authenticator in processing unary requests.
|
||||
func UnaryAuthorizeInterceptor(authenticator *auth.Authenticator) 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 err := authenticator.Authenticate(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestStreamAuthorizeInterceptor(t *testing.T) {
|
||||
})
|
||||
ctx := metadata.NewIncomingContext(context.Background(), md)
|
||||
stream := mockedStream{ctx: ctx}
|
||||
err = interceptor(nil, stream, nil, func(_ interface{}, _ grpc.ServerStream) error {
|
||||
err = interceptor(nil, stream, nil, func(_ any, _ grpc.ServerStream) error {
|
||||
return nil
|
||||
})
|
||||
if test.hasError {
|
||||
@@ -131,7 +131,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) {
|
||||
})
|
||||
ctx := metadata.NewIncomingContext(context.Background(), md)
|
||||
_, err = interceptor(ctx, nil, nil,
|
||||
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
if test.hasError {
|
||||
@@ -141,7 +141,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) {
|
||||
}
|
||||
if test.strict {
|
||||
_, err = interceptor(context.Background(), nil, nil,
|
||||
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
@@ -149,7 +149,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) {
|
||||
var md metadata.MD
|
||||
ctx := metadata.NewIncomingContext(context.Background(), md)
|
||||
_, err = interceptor(ctx, nil, nil,
|
||||
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
@@ -160,7 +160,7 @@ func TestUnaryAuthorizeInterceptor(t *testing.T) {
|
||||
})
|
||||
ctx = metadata.NewIncomingContext(context.Background(), md)
|
||||
_, err = interceptor(ctx, nil, nil,
|
||||
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
@@ -188,10 +188,10 @@ func (m mockedStream) Context() context.Context {
|
||||
return m.ctx
|
||||
}
|
||||
|
||||
func (m mockedStream) SendMsg(v interface{}) error {
|
||||
func (m mockedStream) SendMsg(v any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m mockedStream) RecvMsg(v interface{}) error {
|
||||
func (m mockedStream) RecvMsg(v any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// StreamBreakerInterceptor is an interceptor that acts as a circuit breaker.
|
||||
func StreamBreakerInterceptor(svr interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo,
|
||||
func StreamBreakerInterceptor(svr any, stream grpc.ServerStream, info *grpc.StreamServerInfo,
|
||||
handler grpc.StreamHandler) (err error) {
|
||||
breakerName := info.FullMethod
|
||||
return breaker.DoWithAcceptable(breakerName, func() error {
|
||||
@@ -18,8 +18,8 @@ func StreamBreakerInterceptor(svr interface{}, stream grpc.ServerStream, info *g
|
||||
}
|
||||
|
||||
// UnaryBreakerInterceptor is an interceptor that acts as a circuit breaker.
|
||||
func UnaryBreakerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
func UnaryBreakerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (resp any, err error) {
|
||||
breakerName := info.FullMethod
|
||||
err = breaker.DoWithAcceptable(breakerName, func() error {
|
||||
var err error
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestStreamBreakerInterceptor(t *testing.T) {
|
||||
err := StreamBreakerInterceptor(nil, nil, &grpc.StreamServerInfo{
|
||||
FullMethod: "any",
|
||||
}, func(_ interface{}, _ grpc.ServerStream) error {
|
||||
}, func(_ any, _ grpc.ServerStream) error {
|
||||
return status.New(codes.DeadlineExceeded, "any").Err()
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
@@ -22,7 +22,7 @@ func TestStreamBreakerInterceptor(t *testing.T) {
|
||||
func TestUnaryBreakerInterceptor(t *testing.T) {
|
||||
_, err := UnaryBreakerInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "any",
|
||||
}, func(_ context.Context, _ interface{}) (interface{}, error) {
|
||||
}, func(_ context.Context, _ any) (any, error) {
|
||||
return nil, status.New(codes.DeadlineExceeded, "any").Err()
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
|
||||
@@ -33,8 +33,8 @@ var (
|
||||
)
|
||||
|
||||
// UnaryPrometheusInterceptor reports the statistics to the prometheus server.
|
||||
func UnaryPrometheusInterceptor(ctx context.Context, req interface{},
|
||||
info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func UnaryPrometheusInterceptor(ctx context.Context, req any,
|
||||
info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
startTime := timex.Now()
|
||||
resp, err := handler(ctx, req)
|
||||
metricServerReqDur.Observe(int64(timex.Since(startTime)/time.Millisecond), info.FullMethod)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestUnaryPromMetricInterceptor_Disabled(t *testing.T) {
|
||||
_, err := UnaryPrometheusInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
@@ -25,7 +25,7 @@ func TestUnaryPromMetricInterceptor_Enabled(t *testing.T) {
|
||||
})
|
||||
_, err := UnaryPrometheusInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
)
|
||||
|
||||
// StreamRecoverInterceptor catches panics in processing stream requests and recovers.
|
||||
func StreamRecoverInterceptor(svr interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo,
|
||||
func StreamRecoverInterceptor(svr any, stream grpc.ServerStream, _ *grpc.StreamServerInfo,
|
||||
handler grpc.StreamHandler) (err error) {
|
||||
defer handleCrash(func(r interface{}) {
|
||||
defer handleCrash(func(r any) {
|
||||
err = toPanicError(r)
|
||||
})
|
||||
|
||||
@@ -21,22 +21,22 @@ func StreamRecoverInterceptor(svr interface{}, stream grpc.ServerStream, _ *grpc
|
||||
}
|
||||
|
||||
// UnaryRecoverInterceptor catches panics in processing unary requests and recovers.
|
||||
func UnaryRecoverInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
defer handleCrash(func(r interface{}) {
|
||||
func UnaryRecoverInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (resp any, err error) {
|
||||
defer handleCrash(func(r any) {
|
||||
err = toPanicError(r)
|
||||
})
|
||||
|
||||
return handler(ctx, req)
|
||||
}
|
||||
|
||||
func handleCrash(handler func(interface{})) {
|
||||
func handleCrash(handler func(any)) {
|
||||
if r := recover(); r != nil {
|
||||
handler(r)
|
||||
}
|
||||
}
|
||||
|
||||
func toPanicError(r interface{}) error {
|
||||
func toPanicError(r any) error {
|
||||
logx.Errorf("%+v\n\n%s", r, debug.Stack())
|
||||
return status.Errorf(codes.Internal, "panic: %v", r)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func init() {
|
||||
|
||||
func TestStreamCrashInterceptor(t *testing.T) {
|
||||
err := StreamRecoverInterceptor(nil, nil, nil, func(
|
||||
svr interface{}, stream grpc.ServerStream) error {
|
||||
svr any, stream grpc.ServerStream) error {
|
||||
panic("mock panic")
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
@@ -23,7 +23,7 @@ func TestStreamCrashInterceptor(t *testing.T) {
|
||||
|
||||
func TestUnaryCrashInterceptor(t *testing.T) {
|
||||
_, err := UnaryRecoverInterceptor(context.Background(), nil, nil,
|
||||
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
func(ctx context.Context, req any) (any, error) {
|
||||
panic("mock panic")
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
|
||||
@@ -20,8 +20,8 @@ var (
|
||||
func UnarySheddingInterceptor(shedder load.Shedder, metrics *stat.Metrics) grpc.UnaryServerInterceptor {
|
||||
ensureSheddingStat()
|
||||
|
||||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (val interface{}, err error) {
|
||||
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (val any, err error) {
|
||||
sheddingStat.IncrementTotal()
|
||||
var promise load.Promise
|
||||
promise, err = shedder.Allow()
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestUnarySheddingInterceptor(t *testing.T) {
|
||||
interceptor := UnarySheddingInterceptor(shedder, metrics)
|
||||
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, test.handleErr
|
||||
})
|
||||
assert.Equal(t, test.expect, err)
|
||||
|
||||
@@ -34,8 +34,8 @@ func SetSlowThreshold(threshold time.Duration) {
|
||||
|
||||
// UnaryStatInterceptor returns a func that uses given metrics to report stats.
|
||||
func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor {
|
||||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (resp any, err error) {
|
||||
startTime := timex.Now()
|
||||
defer func() {
|
||||
duration := timex.Since(startTime)
|
||||
@@ -49,7 +49,7 @@ func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor {
|
||||
}
|
||||
}
|
||||
|
||||
func logDuration(ctx context.Context, method string, req interface{}, duration time.Duration) {
|
||||
func logDuration(ctx context.Context, method string, req any, duration time.Duration) {
|
||||
var addr string
|
||||
client, ok := peer.FromContext(ctx)
|
||||
if ok {
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestUnaryStatInterceptor(t *testing.T) {
|
||||
interceptor := UnaryStatInterceptor(metrics)
|
||||
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
@@ -38,7 +38,7 @@ func TestLogDuration(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
ctx context.Context
|
||||
req interface{}
|
||||
req any
|
||||
duration time.Duration
|
||||
}{
|
||||
{
|
||||
@@ -92,7 +92,7 @@ func TestLogDurationWithoutContent(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
ctx context.Context
|
||||
req interface{}
|
||||
req any
|
||||
duration time.Duration
|
||||
}{
|
||||
{
|
||||
|
||||
@@ -15,17 +15,17 @@ import (
|
||||
|
||||
// UnaryTimeoutInterceptor returns a func that sets timeout to incoming unary requests.
|
||||
func UnaryTimeoutInterceptor(timeout time.Duration) 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) {
|
||||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
|
||||
var resp interface{}
|
||||
var resp any
|
||||
var err error
|
||||
var lock sync.Mutex
|
||||
done := make(chan struct{})
|
||||
// create channel with buffer size 1 to avoid goroutine leak
|
||||
panicChan := make(chan interface{}, 1)
|
||||
panicChan := make(chan any, 1)
|
||||
go func() {
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
|
||||
@@ -16,7 +16,7 @@ func TestUnaryTimeoutInterceptor(t *testing.T) {
|
||||
interceptor := UnaryTimeoutInterceptor(time.Millisecond * 10)
|
||||
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
@@ -27,7 +27,7 @@ func TestUnaryTimeoutInterceptor_panic(t *testing.T) {
|
||||
assert.Panics(t, func() {
|
||||
_, _ = interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
panic("any")
|
||||
})
|
||||
})
|
||||
@@ -42,7 +42,7 @@ func TestUnaryTimeoutInterceptor_timeout(t *testing.T) {
|
||||
wg.Add(1)
|
||||
_, err := interceptor(ctx, nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
defer wg.Done()
|
||||
tm, ok := ctx.Deadline()
|
||||
assert.True(t, ok)
|
||||
@@ -62,7 +62,7 @@ func TestUnaryTimeoutInterceptor_timeoutExpire(t *testing.T) {
|
||||
wg.Add(1)
|
||||
_, err := interceptor(ctx, nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
defer wg.Done()
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
return nil, nil
|
||||
@@ -81,7 +81,7 @@ func TestUnaryTimeoutInterceptor_cancel(t *testing.T) {
|
||||
wg.Add(1)
|
||||
_, err := interceptor(ctx, nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
defer wg.Done()
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
return nil, nil
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
)
|
||||
|
||||
// UnaryTracingInterceptor is a grpc.UnaryServerInterceptor for opentelemetry.
|
||||
func UnaryTracingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func UnaryTracingInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo,
|
||||
handler grpc.UnaryHandler) (any, error) {
|
||||
ctx, span := startSpan(ctx, info.FullMethod)
|
||||
defer span.End()
|
||||
|
||||
@@ -41,7 +41,7 @@ func UnaryTracingInterceptor(ctx context.Context, req interface{}, info *grpc.Un
|
||||
}
|
||||
|
||||
// StreamTracingInterceptor returns a grpc.StreamServerInterceptor for opentelemetry.
|
||||
func StreamTracingInterceptor(svr interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo,
|
||||
func StreamTracingInterceptor(svr any, ss grpc.ServerStream, info *grpc.StreamServerInfo,
|
||||
handler grpc.StreamHandler) error {
|
||||
ctx, span := startSpan(ss.Context(), info.FullMethod)
|
||||
defer span.End()
|
||||
@@ -74,7 +74,7 @@ func (w *serverStream) Context() context.Context {
|
||||
return w.ctx
|
||||
}
|
||||
|
||||
func (w *serverStream) RecvMsg(m interface{}) error {
|
||||
func (w *serverStream) RecvMsg(m any) error {
|
||||
err := w.ServerStream.RecvMsg(m)
|
||||
if err == nil {
|
||||
w.receivedMessageID++
|
||||
@@ -84,7 +84,7 @@ func (w *serverStream) RecvMsg(m interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *serverStream) SendMsg(m interface{}) error {
|
||||
func (w *serverStream) SendMsg(m any) error {
|
||||
err := w.ServerStream.SendMsg(m)
|
||||
w.sentMessageID++
|
||||
ztrace.MessageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
func TestUnaryOpenTracingInterceptor_Disable(t *testing.T) {
|
||||
_, err := UnaryTracingInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
@@ -36,7 +36,7 @@ func TestUnaryOpenTracingInterceptor_Enabled(t *testing.T) {
|
||||
|
||||
_, err := UnaryTracingInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/package.TestService.GetUser",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
return nil, nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
@@ -48,7 +48,7 @@ func TestUnaryTracingInterceptor(t *testing.T) {
|
||||
wg.Add(1)
|
||||
_, err := UnaryTracingInterceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
defer wg.Done()
|
||||
atomic.AddInt32(&run, 1)
|
||||
return nil, nil
|
||||
@@ -84,7 +84,7 @@ func TestUnaryTracingInterceptor_WithError(t *testing.T) {
|
||||
ctx := metadata.NewIncomingContext(context.Background(), md)
|
||||
_, err := UnaryTracingInterceptor(ctx, nil, &grpc.UnaryServerInfo{
|
||||
FullMethod: "/",
|
||||
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
}, func(ctx context.Context, req any) (any, error) {
|
||||
defer wg.Done()
|
||||
return nil, test.err
|
||||
})
|
||||
@@ -103,7 +103,7 @@ func TestStreamTracingInterceptor_GrpcFormat(t *testing.T) {
|
||||
stream := mockedServerStream{ctx: ctx}
|
||||
err := StreamTracingInterceptor(nil, &stream, &grpc.StreamServerInfo{
|
||||
FullMethod: "/foo",
|
||||
}, func(svr interface{}, stream grpc.ServerStream) error {
|
||||
}, func(svr any, stream grpc.ServerStream) error {
|
||||
defer wg.Done()
|
||||
atomic.AddInt32(&run, 1)
|
||||
return nil
|
||||
@@ -140,7 +140,7 @@ func TestStreamTracingInterceptor_FinishWithGrpcError(t *testing.T) {
|
||||
stream := mockedServerStream{ctx: ctx}
|
||||
err := StreamTracingInterceptor(nil, &stream, &grpc.StreamServerInfo{
|
||||
FullMethod: "/foo",
|
||||
}, func(svr interface{}, stream grpc.ServerStream) error {
|
||||
}, func(svr any, stream grpc.ServerStream) error {
|
||||
defer wg.Done()
|
||||
return test.err
|
||||
})
|
||||
@@ -177,7 +177,7 @@ func TestStreamTracingInterceptor_WithError(t *testing.T) {
|
||||
stream := mockedServerStream{ctx: ctx}
|
||||
err := StreamTracingInterceptor(nil, &stream, &grpc.StreamServerInfo{
|
||||
FullMethod: "/foo",
|
||||
}, func(svr interface{}, stream grpc.ServerStream) error {
|
||||
}, func(svr any, stream grpc.ServerStream) error {
|
||||
defer wg.Done()
|
||||
return test.err
|
||||
})
|
||||
@@ -270,10 +270,10 @@ func (m *mockedServerStream) Context() context.Context {
|
||||
return m.ctx
|
||||
}
|
||||
|
||||
func (m *mockedServerStream) SendMsg(v interface{}) error {
|
||||
func (m *mockedServerStream) SendMsg(v any) error {
|
||||
return m.err
|
||||
}
|
||||
|
||||
func (m *mockedServerStream) RecvMsg(v interface{}) error {
|
||||
func (m *mockedServerStream) RecvMsg(v any) error {
|
||||
return m.err
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewProxy(backend string, opts ...internal.ClientOption) *RpcProxy {
|
||||
func (p *RpcProxy) TakeConn(ctx context.Context) (*grpc.ClientConn, error) {
|
||||
cred := auth.ParseCredential(ctx)
|
||||
key := cred.App + "/" + cred.Token
|
||||
val, err := p.singleFlight.Do(key, func() (interface{}, error) {
|
||||
val, err := p.singleFlight.Do(key, func() (any, error) {
|
||||
p.lock.Lock()
|
||||
client, ok := p.clients[key]
|
||||
p.lock.Unlock()
|
||||
|
||||
@@ -24,7 +24,7 @@ func NewEventHandler(update func([]string)) *EventHandler {
|
||||
}
|
||||
|
||||
// OnAdd handles the endpoints add events.
|
||||
func (h *EventHandler) OnAdd(obj interface{}) {
|
||||
func (h *EventHandler) OnAdd(obj any) {
|
||||
endpoints, ok := obj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
logx.Errorf("%v is not an object with type *v1.Endpoints", obj)
|
||||
@@ -50,7 +50,7 @@ func (h *EventHandler) OnAdd(obj interface{}) {
|
||||
}
|
||||
|
||||
// OnDelete handles the endpoints delete events.
|
||||
func (h *EventHandler) OnDelete(obj interface{}) {
|
||||
func (h *EventHandler) OnDelete(obj any) {
|
||||
endpoints, ok := obj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
logx.Errorf("%v is not an object with type *v1.Endpoints", obj)
|
||||
@@ -76,7 +76,7 @@ func (h *EventHandler) OnDelete(obj interface{}) {
|
||||
}
|
||||
|
||||
// OnUpdate handles the endpoints update events.
|
||||
func (h *EventHandler) OnUpdate(oldObj, newObj interface{}) {
|
||||
func (h *EventHandler) OnUpdate(oldObj, newObj any) {
|
||||
oldEndpoints, ok := oldObj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
logx.Errorf("%v is not an object with type *v1.Endpoints", oldObj)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestSubset(t *testing.T) {
|
||||
vals = append(vals, strconv.Itoa(i))
|
||||
}
|
||||
|
||||
m := make(map[interface{}]int)
|
||||
m := make(map[any]int)
|
||||
for i := 0; i < 1000; i++ {
|
||||
set := subset(append([]string(nil), vals...), test.sub)
|
||||
if test.sub < test.set {
|
||||
|
||||
Reference in New Issue
Block a user