Merge pull request #991 from go-kratos/feat/delete_grpc_recovery

delete grpc recovery
pull/992/head
longxboy 4 years ago committed by GitHub
commit bfc79d5ef0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      transport/grpc/client.go
  2. 8
      transport/grpc/server.go
  3. 8
      transport/http/handle.go

@ -5,7 +5,6 @@ import (
"time" "time"
"github.com/go-kratos/kratos/v2/middleware" "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/registry"
"github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport"
"github.com/go-kratos/kratos/v2/transport/grpc/resolver/discovery" "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) { func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.ClientConn, error) {
options := clientOptions{ options := clientOptions{
timeout: 500 * time.Millisecond, timeout: 500 * time.Millisecond,
middleware: middleware.Chain(
recovery.Recovery(),
),
} }
for _, o := range opts { for _, o := range opts {
o(&options) o(&options)

@ -12,7 +12,6 @@ import (
"github.com/go-kratos/kratos/v2/internal/host" "github.com/go-kratos/kratos/v2/internal/host"
"github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/middleware"
"github.com/go-kratos/kratos/v2/middleware/recovery"
"github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/health" "google.golang.org/grpc/health"
@ -100,11 +99,8 @@ func NewServer(opts ...ServerOption) *Server {
network: "tcp", network: "tcp",
address: ":0", address: ":0",
timeout: 1 * time.Second, timeout: 1 * time.Second,
middleware: middleware.Chain( health: health.NewServer(),
recovery.Recovery(), log: log.NewHelper(log.DefaultLogger),
),
health: health.NewServer(),
log: log.NewHelper(log.DefaultLogger),
} }
for _, o := range opts { for _, o := range opts {
o(srv) o(srv)

@ -11,7 +11,6 @@ import (
"github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/errors"
"github.com/go-kratos/kratos/v2/internal/httputil" "github.com/go-kratos/kratos/v2/internal/httputil"
"github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/middleware"
"github.com/go-kratos/kratos/v2/middleware/recovery"
"github.com/go-kratos/kratos/v2/transport/http/binding" "github.com/go-kratos/kratos/v2/transport/http/binding"
) )
@ -43,10 +42,9 @@ type HandleOptions struct {
// Deprecated: use NewHandler instead. // Deprecated: use NewHandler instead.
func DefaultHandleOptions() HandleOptions { func DefaultHandleOptions() HandleOptions {
return HandleOptions{ return HandleOptions{
Decode: DefaultRequestDecoder, Decode: DefaultRequestDecoder,
Encode: DefaultResponseEncoder, Encode: DefaultResponseEncoder,
Error: DefaultErrorEncoder, Error: DefaultErrorEncoder,
Middleware: recovery.Recovery(),
} }
} }

Loading…
Cancel
Save