Browse Source

Delete duplicated crash recover logic. (#1950)

* Update statinterceptor.go

* Update statinterceptor_test.go
kunyu 2 năm trước cách đây
mục cha
commit
65098d4737

+ 1 - 4
zrpc/internal/serverinterceptors/statinterceptor.go

@@ -26,10 +26,7 @@ func SetSlowThreshold(threshold time.Duration) {
 func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor {
 func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor {
 	return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
 	return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
 		handler grpc.UnaryHandler) (resp interface{}, err error) {
 		handler grpc.UnaryHandler) (resp interface{}, err error) {
-		defer handleCrash(func(r interface{}) {
-			err = toPanicError(r)
-		})
-
+		
 		startTime := timex.Now()
 		startTime := timex.Now()
 		defer func() {
 		defer func() {
 			duration := timex.Since(startTime)
 			duration := timex.Since(startTime)

+ 0 - 11
zrpc/internal/serverinterceptors/statinterceptor_test.go

@@ -30,17 +30,6 @@ func TestUnaryStatInterceptor(t *testing.T) {
 	assert.Nil(t, err)
 	assert.Nil(t, err)
 }
 }
 
 
-func TestUnaryStatInterceptor_crash(t *testing.T) {
-	metrics := stat.NewMetrics("mock")
-	interceptor := UnaryStatInterceptor(metrics)
-	_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
-		FullMethod: "/",
-	}, func(ctx context.Context, req interface{}) (interface{}, error) {
-		panic("error")
-	})
-	assert.NotNil(t, err)
-}
-
 func TestLogDuration(t *testing.T) {
 func TestLogDuration(t *testing.T) {
 	addrs, err := net.InterfaceAddrs()
 	addrs, err := net.InterfaceAddrs()
 	assert.Nil(t, err)
 	assert.Nil(t, err)