Replace interface{} with any #29

Merged
fyrchik merged 1 commit from acid-ant/frostfs-api-go:feature/28-use-any into master 2023-05-15 16:08:23 +00:00
8 changed files with 14 additions and 14 deletions

View file

@ -15,7 +15,7 @@ import (
// NewGRPCUnaryClientInteceptor creates new gRPC unary interceptor to save gRPC client traces.
func NewGRPCUnaryClientInteceptor() grpc.UnaryClientInterceptor {
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, span := startClientSpan(ctx, cc, method)
defer span.End()
@ -74,7 +74,7 @@ func NewGRPCStreamClientInterceptor() grpc.StreamClientInterceptor {
// NewGRPCUnaryServerInterceptor creates new gRPC unary interceptor to save gRPC server traces.
func NewGRPCUnaryServerInterceptor() 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 interface{}, err error) {
ctx = extractGRPCTraceInfo(ctx)
var span trace.Span
ctx, span = StartSpanFromContext(ctx, info.FullMethod,
@ -94,7 +94,7 @@ func NewGRPCUnaryServerInterceptor() grpc.UnaryServerInterceptor {
// NewGRPCStreamServerInterceptor creates new gRPC stream interceptor to save gRPC server traces.
func NewGRPCStreamServerInterceptor() grpc.StreamServerInterceptor {
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 {
ctx := extractGRPCTraceInfo(ss.Context())
var span trace.Span
ctx, span = StartSpanFromContext(ctx, info.FullMethod,

View file

@ -100,7 +100,7 @@ func (cs *clientStream) Context() context.Context {
return cs.originalStream.Context()
}
func (cs *clientStream) SendMsg(m interface{}) error {
func (cs *clientStream) SendMsg(m any) error {
err := cs.originalStream.SendMsg(m)
if err != nil {
select {
@ -111,7 +111,7 @@ func (cs *clientStream) SendMsg(m interface{}) error {
return err
}
func (cs *clientStream) RecvMsg(m interface{}) error {
func (cs *clientStream) RecvMsg(m any) error {
err := cs.originalStream.RecvMsg(m)
if err != nil || !cs.desc.ServerStreams {
select {
@ -150,10 +150,10 @@ func (ss *serverStream) Context() context.Context {
return ss.ctx
}
func (ss *serverStream) SendMsg(m interface{}) error {
func (ss *serverStream) SendMsg(m any) error {
return ss.originalStream.SendMsg(m)
}
func (ss *serverStream) RecvMsg(m interface{}) error {
func (ss *serverStream) RecvMsg(m any) error {
return ss.originalStream.RecvMsg(m)
}

View file

@ -1,4 +1,4 @@
package grpc
// Message represents raw gRPC message.
type Message interface{}
type Message any

View file

@ -26,12 +26,12 @@ type Message interface {
// ErrUnexpectedMessageType is an error that
// is used to indicate message mismatch.
type ErrUnexpectedMessageType struct {
exp, act interface{}
exp, act any
}
// NewUnexpectedMessageType initializes an error about message mismatch
// between act and exp.
func NewUnexpectedMessageType(act, exp interface{}) ErrUnexpectedMessageType {
func NewUnexpectedMessageType(act, exp any) ErrUnexpectedMessageType {
return ErrUnexpectedMessageType{
exp: exp,
act: act,

View file

@ -11,7 +11,7 @@ import (
)
// nolint:funlen
func serviceMessageBody(req interface{}) stableMarshaler {
func serviceMessageBody(req any) stableMarshaler {
switch v := req.(type) {
default:
panic(fmt.Sprintf("unsupported session message %T", req))

View file

@ -29,7 +29,7 @@ type signatureReceiver interface {
}
// SignServiceMessage signes service message with key.
func SignServiceMessage(key *ecdsa.PrivateKey, msg interface{}) error {
func SignServiceMessage(key *ecdsa.PrivateKey, msg any) error {
switch v := msg.(type) {
case nil:
return nil

View file

@ -17,7 +17,7 @@ type signatureProvider interface {
}
// VerifyServiceMessage verifies service message.
func VerifyServiceMessage(msg interface{}) error {
func VerifyServiceMessage(msg any) error {
switch v := msg.(type) {
case nil:
return nil

View file

@ -12,7 +12,7 @@ import (
func TestCodes(t *testing.T,
localizer func(*status.Code) bool,
globalizer func(code *status.Code),
vals ...interface{},
vals ...any,
) {
for i := 0; i < len(vals); i += 2 {
c := vals[i].(status.Code)