mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-09 12:39:02 +08:00
1
This commit is contained in:
parent
f5fc429b34
commit
8431b40c16
@ -4,7 +4,6 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/trace_log"
|
"Open_IM/pkg/common/trace_log"
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -60,25 +59,26 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func RpcClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) {
|
|
||||||
//if cc == nil {
|
|
||||||
// return utils.Wrap(constant.ErrRpcConn, "")
|
|
||||||
//}
|
|
||||||
operationID, ok := ctx.Value("operationID").(string)
|
|
||||||
if !ok {
|
|
||||||
return utils.Wrap(constant.ErrArgs, "ctx missing operationID")
|
|
||||||
}
|
|
||||||
opUserID, ok := ctx.Value("opUserID").(string)
|
|
||||||
if !ok {
|
|
||||||
return utils.Wrap(constant.ErrArgs, "ctx missing opUserID")
|
|
||||||
}
|
|
||||||
md := metadata.Pairs("operationID", operationID, "opUserID", opUserID)
|
|
||||||
return invoker(metadata.NewOutgoingContext(ctx, md), method, req, reply, cc, opts...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func rpcString(v interface{}) string {
|
func rpcString(v interface{}) string {
|
||||||
if s, ok := v.(interface{ String() string }); ok {
|
if s, ok := v.(interface{ String() string }); ok {
|
||||||
return s.String()
|
return s.String()
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%+v", v)
|
return fmt.Sprintf("%+v", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//func RpcClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) {
|
||||||
|
// //if cc == nil {
|
||||||
|
// // return utils.Wrap(constant.ErrRpcConn, "")
|
||||||
|
// //}
|
||||||
|
// operationID, ok := ctx.Value("operationID").(string)
|
||||||
|
// if !ok {
|
||||||
|
// return utils.Wrap(constant.ErrArgs, "ctx missing operationID")
|
||||||
|
// }
|
||||||
|
// opUserID, ok := ctx.Value("opUserID").(string)
|
||||||
|
// if !ok {
|
||||||
|
// return utils.Wrap(constant.ErrArgs, "ctx missing opUserID")
|
||||||
|
// }
|
||||||
|
// md := metadata.Pairs("operationID", operationID, "opUserID", opUserID)
|
||||||
|
// return invoker(metadata.NewOutgoingContext(ctx, md), method, req, reply, cc, opts...)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user