mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-10 13:09:01 +08:00
1
This commit is contained in:
parent
b57616cb29
commit
3b82fbe4ca
@ -4,10 +4,10 @@ import (
|
|||||||
"Open_IM/pkg/common/trace_log"
|
"Open_IM/pkg/common/trace_log"
|
||||||
"Open_IM/pkg/getcdv3"
|
"Open_IM/pkg/getcdv3"
|
||||||
utils2 "Open_IM/pkg/utils"
|
utils2 "Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
utils "github.com/OpenIMSDK/open_utils"
|
utils "github.com/OpenIMSDK/open_utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,10 +44,11 @@ func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcCl
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
trace_log.SetContextInfo(nCtx, logFuncName, nil, "opUserID", opUserID, "callRpcReq", rpcString(rpcReqPtr.Elem().Interface()))
|
trace_log.SetContextInfo(nCtx, logFuncName, nil, "opUserID", opUserID, "callRpcReq", rpcString(rpcReqPtr.Elem().Interface()))
|
||||||
md := metadata.Pairs("operationID", operationID, "opUserID", opUserID)
|
//md := metadata.Pairs("operationID", operationID, "opUserID", opUserID)
|
||||||
respArr := rpc.Call([]reflect.Value{
|
respArr := rpc.Call([]reflect.Value{
|
||||||
reflect.ValueOf(metadata.NewOutgoingContext(c, md)), // context.Context
|
//reflect.ValueOf(metadata.NewOutgoingContext(c, md)), // context.Context
|
||||||
rpcReqPtr, // rpc apiReq
|
reflect.ValueOf(context.Context(c)), // context.Context
|
||||||
|
rpcReqPtr, // rpc apiReq
|
||||||
}) // respArr => (apiResp, error)
|
}) // respArr => (apiResp, error)
|
||||||
if !respArr[1].IsNil() { // rpc err != nil
|
if !respArr[1].IsNil() { // rpc err != nil
|
||||||
err := respArr[1].Interface().(error)
|
err := respArr[1].Interface().(error)
|
||||||
|
@ -34,9 +34,7 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
|||||||
operationID = opts[0]
|
operationID = opts[0]
|
||||||
}
|
}
|
||||||
var opUserID string
|
var opUserID string
|
||||||
if opts := md.Get("opUserID"); len(opts) != 1 {
|
if opts := md.Get("opUserID"); len(opts) == 1 {
|
||||||
return nil, status.New(codes.InvalidArgument, "opUserID error").Err()
|
|
||||||
} else {
|
|
||||||
opUserID = opts[0]
|
opUserID = opts[0]
|
||||||
}
|
}
|
||||||
ctx = trace_log.NewRpcCtx(ctx, funcName, operationID)
|
ctx = trace_log.NewRpcCtx(ctx, funcName, operationID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user