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:
Kevin Wan
2023-01-24 16:32:02 +08:00
committed by GitHub
parent 7e0ac77139
commit ae87114282
221 changed files with 1910 additions and 2207 deletions

View File

@@ -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 {

View File

@@ -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
})

View File

@@ -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()

View File

@@ -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
})

View File

@@ -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...)

View File

@@ -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
})

View File

@@ -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...)

View File

@@ -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")
},

View File

@@ -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)

View File

@@ -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
}