Merge branch 'v3' into dependabot/github_actions/golangci/golangci-lint-action-3.3.0
This commit is contained in:
commit
14df5e18cb
50
grpc.go
50
grpc.go
@ -197,31 +197,6 @@ func (g *grpcServer) getGrpcOptions() []grpc.ServerOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *grpcServer) handler(srv interface{}, stream grpc.ServerStream) (err error) {
|
func (g *grpcServer) handler(srv interface{}, stream grpc.ServerStream) (err error) {
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
g.RLock()
|
|
||||||
config := g.opts
|
|
||||||
g.RUnlock()
|
|
||||||
if config.Logger.V(logger.ErrorLevel) {
|
|
||||||
config.Logger.Error(config.Context, "panic recovered: ", r)
|
|
||||||
config.Logger.Error(config.Context, string(debug.Stack()))
|
|
||||||
}
|
|
||||||
err = errors.InternalServerError(g.opts.Name, "panic recovered: %v", r)
|
|
||||||
} else if err != nil {
|
|
||||||
g.RLock()
|
|
||||||
config := g.opts
|
|
||||||
g.RUnlock()
|
|
||||||
if config.Logger.V(logger.ErrorLevel) {
|
|
||||||
config.Logger.Errorf(config.Context, "grpc handler got error: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if g.wg != nil {
|
|
||||||
g.wg.Add(1)
|
|
||||||
defer g.wg.Done()
|
|
||||||
}
|
|
||||||
|
|
||||||
fullMethod, ok := grpc.MethodFromServerStream(stream)
|
fullMethod, ok := grpc.MethodFromServerStream(stream)
|
||||||
if !ok {
|
if !ok {
|
||||||
return status.Errorf(codes.Internal, "method does not exist in context")
|
return status.Errorf(codes.Internal, "method does not exist in context")
|
||||||
@ -232,6 +207,31 @@ func (g *grpcServer) handler(srv interface{}, stream grpc.ServerStream) (err err
|
|||||||
return status.New(codes.InvalidArgument, err.Error()).Err()
|
return status.New(codes.InvalidArgument, err.Error()).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
g.RLock()
|
||||||
|
config := g.opts
|
||||||
|
g.RUnlock()
|
||||||
|
if config.Logger.V(logger.ErrorLevel) {
|
||||||
|
config.Logger.Errorf(config.Context, "panic in %s.%s recovered: %v", serviceName, methodName, r)
|
||||||
|
config.Logger.Error(config.Context, string(debug.Stack()))
|
||||||
|
}
|
||||||
|
err = errors.InternalServerError(g.opts.Name, "panic in %s.%s recovered: %v", serviceName, methodName, r)
|
||||||
|
} else if err != nil {
|
||||||
|
g.RLock()
|
||||||
|
config := g.opts
|
||||||
|
g.RUnlock()
|
||||||
|
if config.Logger.V(logger.ErrorLevel) {
|
||||||
|
config.Logger.Errorf(config.Context, "grpc handler %s.%s got error: %s", serviceName, methodName, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if g.wg != nil {
|
||||||
|
g.wg.Add(1)
|
||||||
|
defer g.wg.Done()
|
||||||
|
}
|
||||||
|
|
||||||
// get grpc metadata
|
// get grpc metadata
|
||||||
gmd, ok := gmetadata.FromIncomingContext(stream.Context())
|
gmd, ok := gmetadata.FromIncomingContext(stream.Context())
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user