forked from TrueCloudLab/frostfs-api-go
[#28] Replace interface{} with any
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
e9e7901f67
commit
a3a5046ecc
8 changed files with 14 additions and 14 deletions
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
// NewGRPCUnaryClientInteceptor creates new gRPC unary interceptor to save gRPC client traces.
|
// NewGRPCUnaryClientInteceptor creates new gRPC unary interceptor to save gRPC client traces.
|
||||||
func NewGRPCUnaryClientInteceptor() grpc.UnaryClientInterceptor {
|
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)
|
ctx, span := startClientSpan(ctx, cc, method)
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ func NewGRPCStreamClientInterceptor() grpc.StreamClientInterceptor {
|
||||||
|
|
||||||
// NewGRPCUnaryServerInterceptor creates new gRPC unary interceptor to save gRPC server traces.
|
// NewGRPCUnaryServerInterceptor creates new gRPC unary interceptor to save gRPC server traces.
|
||||||
func NewGRPCUnaryServerInterceptor() grpc.UnaryServerInterceptor {
|
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)
|
ctx = extractGRPCTraceInfo(ctx)
|
||||||
var span trace.Span
|
var span trace.Span
|
||||||
ctx, span = StartSpanFromContext(ctx, info.FullMethod,
|
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.
|
// NewGRPCStreamServerInterceptor creates new gRPC stream interceptor to save gRPC server traces.
|
||||||
func NewGRPCStreamServerInterceptor() grpc.StreamServerInterceptor {
|
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())
|
ctx := extractGRPCTraceInfo(ss.Context())
|
||||||
var span trace.Span
|
var span trace.Span
|
||||||
ctx, span = StartSpanFromContext(ctx, info.FullMethod,
|
ctx, span = StartSpanFromContext(ctx, info.FullMethod,
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (cs *clientStream) Context() context.Context {
|
||||||
return cs.originalStream.Context()
|
return cs.originalStream.Context()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *clientStream) SendMsg(m interface{}) error {
|
func (cs *clientStream) SendMsg(m any) error {
|
||||||
err := cs.originalStream.SendMsg(m)
|
err := cs.originalStream.SendMsg(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
select {
|
select {
|
||||||
|
@ -111,7 +111,7 @@ func (cs *clientStream) SendMsg(m interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *clientStream) RecvMsg(m interface{}) error {
|
func (cs *clientStream) RecvMsg(m any) error {
|
||||||
err := cs.originalStream.RecvMsg(m)
|
err := cs.originalStream.RecvMsg(m)
|
||||||
if err != nil || !cs.desc.ServerStreams {
|
if err != nil || !cs.desc.ServerStreams {
|
||||||
select {
|
select {
|
||||||
|
@ -150,10 +150,10 @@ func (ss *serverStream) Context() context.Context {
|
||||||
return ss.ctx
|
return ss.ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *serverStream) SendMsg(m interface{}) error {
|
func (ss *serverStream) SendMsg(m any) error {
|
||||||
return ss.originalStream.SendMsg(m)
|
return ss.originalStream.SendMsg(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *serverStream) RecvMsg(m interface{}) error {
|
func (ss *serverStream) RecvMsg(m any) error {
|
||||||
return ss.originalStream.RecvMsg(m)
|
return ss.originalStream.RecvMsg(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
// Message represents raw gRPC message.
|
// Message represents raw gRPC message.
|
||||||
type Message interface{}
|
type Message any
|
||||||
|
|
|
@ -26,12 +26,12 @@ type Message interface {
|
||||||
// ErrUnexpectedMessageType is an error that
|
// ErrUnexpectedMessageType is an error that
|
||||||
// is used to indicate message mismatch.
|
// is used to indicate message mismatch.
|
||||||
type ErrUnexpectedMessageType struct {
|
type ErrUnexpectedMessageType struct {
|
||||||
exp, act interface{}
|
exp, act any
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewUnexpectedMessageType initializes an error about message mismatch
|
// NewUnexpectedMessageType initializes an error about message mismatch
|
||||||
// between act and exp.
|
// between act and exp.
|
||||||
func NewUnexpectedMessageType(act, exp interface{}) ErrUnexpectedMessageType {
|
func NewUnexpectedMessageType(act, exp any) ErrUnexpectedMessageType {
|
||||||
return ErrUnexpectedMessageType{
|
return ErrUnexpectedMessageType{
|
||||||
exp: exp,
|
exp: exp,
|
||||||
act: act,
|
act: act,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint:funlen
|
// nolint:funlen
|
||||||
func serviceMessageBody(req interface{}) stableMarshaler {
|
func serviceMessageBody(req any) stableMarshaler {
|
||||||
switch v := req.(type) {
|
switch v := req.(type) {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("unsupported session message %T", req))
|
panic(fmt.Sprintf("unsupported session message %T", req))
|
||||||
|
|
|
@ -29,7 +29,7 @@ type signatureReceiver interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignServiceMessage signes service message with key.
|
// 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) {
|
switch v := msg.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -17,7 +17,7 @@ type signatureProvider interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyServiceMessage verifies service message.
|
// VerifyServiceMessage verifies service message.
|
||||||
func VerifyServiceMessage(msg interface{}) error {
|
func VerifyServiceMessage(msg any) error {
|
||||||
switch v := msg.(type) {
|
switch v := msg.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
func TestCodes(t *testing.T,
|
func TestCodes(t *testing.T,
|
||||||
localizer func(*status.Code) bool,
|
localizer func(*status.Code) bool,
|
||||||
globalizer func(code *status.Code),
|
globalizer func(code *status.Code),
|
||||||
vals ...interface{},
|
vals ...any,
|
||||||
) {
|
) {
|
||||||
for i := 0; i < len(vals); i += 2 {
|
for i := 0; i < len(vals); i += 2 {
|
||||||
c := vals[i].(status.Code)
|
c := vals[i].(status.Code)
|
||||||
|
|
Loading…
Reference in a new issue