mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-15 23:29:23 +08:00
1
This commit is contained in:
parent
d142988390
commit
2841109f31
@ -11,13 +11,13 @@ import (
|
||||
|
||||
func ApiToRpc(c *gin.Context, apiReq, apiResp interface{}, rpcName string, rpcClientFunc interface{}, rpcFuncName string, tokenFunc func(token string, operationID string) (string, error)) {
|
||||
operationID := c.GetHeader("operationID")
|
||||
nCtx := trace_log.NewCtx(c, rpcFuncName)
|
||||
nCtx := trace_log.NewCtx1(c, rpcFuncName, operationID)
|
||||
//trace_log.SetOperationID(nCtx, operationID)
|
||||
defer trace_log.ShowLog(nCtx)
|
||||
if err := c.BindJSON(apiReq); err != nil {
|
||||
trace_log.WriteErrorResponse(nCtx, "BindJSON", err)
|
||||
return
|
||||
}
|
||||
trace_log.SetOperationID(nCtx, operationID)
|
||||
trace_log.SetContextInfo(nCtx, "BindJSON", nil, "params", apiReq)
|
||||
etcdConn, err := getcdv3.GetConn(c, rpcName)
|
||||
if err != nil {
|
||||
|
@ -20,6 +20,11 @@ func NewCtx(c *gin.Context, api string) context.Context {
|
||||
return context.WithValue(c, TraceLogKey, req)
|
||||
}
|
||||
|
||||
func NewCtx1(c *gin.Context, api, operationID string) context.Context {
|
||||
req := &ApiInfo{ApiName: api, GinCtx: c, OperationID: operationID, Funcs: &[]FuncInfo{}}
|
||||
return context.WithValue(c, TraceLogKey, req)
|
||||
}
|
||||
|
||||
func NewRpcCtx(c context.Context, rpc string, operationID string) context.Context {
|
||||
req := &ApiInfo{ApiName: rpc, Funcs: &[]FuncInfo{}}
|
||||
ctx := context.WithValue(c, TraceLogKey, req)
|
||||
|
Loading…
x
Reference in New Issue
Block a user