From 864008ea6b2589fc2cb1f33df461b228868c52c9 Mon Sep 17 00:00:00 2001 From: longXboy Date: Tue, 1 Jun 2021 22:12:46 +0800 Subject: [PATCH 1/2] delete grpc recovery --- transport/grpc/client.go | 4 ---- transport/grpc/server.go | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/transport/grpc/client.go b/transport/grpc/client.go index 93dc4f019..e5f37c9b1 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -5,7 +5,6 @@ import ( "time" "github.com/go-kratos/kratos/v2/middleware" - "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/registry" "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/grpc/resolver/discovery" @@ -85,9 +84,6 @@ func DialInsecure(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.ClientConn, error) { options := clientOptions{ timeout: 500 * time.Millisecond, - middleware: middleware.Chain( - recovery.Recovery(), - ), } for _, o := range opts { o(&options) diff --git a/transport/grpc/server.go b/transport/grpc/server.go index 56ccb2bbe..af76ea0f7 100644 --- a/transport/grpc/server.go +++ b/transport/grpc/server.go @@ -12,7 +12,6 @@ import ( "github.com/go-kratos/kratos/v2/internal/host" "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/middleware" - "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/transport" "google.golang.org/grpc" "google.golang.org/grpc/health" @@ -100,11 +99,8 @@ func NewServer(opts ...ServerOption) *Server { network: "tcp", address: ":0", timeout: 1 * time.Second, - middleware: middleware.Chain( - recovery.Recovery(), - ), - health: health.NewServer(), - log: log.NewHelper(log.DefaultLogger), + health: health.NewServer(), + log: log.NewHelper(log.DefaultLogger), } for _, o := range opts { o(srv) From f90e5874ef6c95c387945d174308f735d0fd9702 Mon Sep 17 00:00:00 2001 From: longXboy Date: Tue, 1 Jun 2021 22:18:42 +0800 Subject: [PATCH 2/2] delete http recovery --- transport/http/handle.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/transport/http/handle.go b/transport/http/handle.go index 6296131ed..1034a251d 100644 --- a/transport/http/handle.go +++ b/transport/http/handle.go @@ -11,7 +11,6 @@ import ( "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/internal/httputil" "github.com/go-kratos/kratos/v2/middleware" - "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/transport/http/binding" ) @@ -43,10 +42,9 @@ type HandleOptions struct { // Deprecated: use NewHandler instead. func DefaultHandleOptions() HandleOptions { return HandleOptions{ - Decode: DefaultRequestDecoder, - Encode: DefaultResponseEncoder, - Error: DefaultErrorEncoder, - Middleware: recovery.Recovery(), + Decode: DefaultRequestDecoder, + Encode: DefaultResponseEncoder, + Error: DefaultErrorEncoder, } }