mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-10 04:59:49 +08:00
1
This commit is contained in:
parent
9b962a0368
commit
6c0175540b
@ -367,7 +367,7 @@ func GetGroupInfoFromCache(ctx context.Context, groupID string) (groupInfo *imdb
|
|||||||
return string(bytes), nil
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupInfo", *groupInfo)
|
trace_log.SetContextInfo(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupInfo", groupInfo)
|
||||||
}()
|
}()
|
||||||
groupInfoStr, err := db.DB.Rc.Fetch(groupInfoCache+groupID, time.Second*30*60, getGroupInfo)
|
groupInfoStr, err := db.DB.Rc.Fetch(groupInfoCache+groupID, time.Second*30*60, getGroupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2,24 +2,32 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/trace_log"
|
"Open_IM/pkg/common/trace_log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||||
|
var operationID string
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
log.NewError(operationID, info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r, "stack:", string(debug.Stack()))
|
||||||
|
}
|
||||||
|
}()
|
||||||
funcName := path.Base(info.FullMethod)
|
funcName := path.Base(info.FullMethod)
|
||||||
md, ok := metadata.FromIncomingContext(ctx)
|
md, ok := metadata.FromIncomingContext(ctx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, status.New(codes.InvalidArgument, "missing metadata").Err()
|
return nil, status.New(codes.InvalidArgument, "missing metadata").Err()
|
||||||
}
|
}
|
||||||
var operationID string
|
|
||||||
if opts := md.Get("operationID"); len(opts) != 1 || opts[0] == "" {
|
if opts := md.Get("operationID"); len(opts) != 1 || opts[0] == "" {
|
||||||
return nil, status.New(codes.InvalidArgument, "operationID error").Err()
|
return nil, status.New(codes.InvalidArgument, "operationID error").Err()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user