Fix context error in grpc (#962)

* Fix context error in rpc

* Add a test case

* Optimize judgment conditions

* Add customized breaker errors for the client and server

* Update method signature

* Delete customized breaker errors

* Delete the wrong test case
This commit is contained in:
chenquan
2021-08-28 12:07:14 +08:00
committed by GitHub
parent 519db812b4
commit dfb3cb510a
4 changed files with 33 additions and 15 deletions

View File

@@ -1,8 +1,6 @@
package codes
import (
"context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -12,17 +10,6 @@ func Acceptable(err error) bool {
switch status.Code(err) {
case codes.DeadlineExceeded, codes.Internal, codes.Unavailable, codes.DataLoss:
return false
case codes.Unknown:
return acceptableUnknown(err)
default:
return true
}
}
func acceptableUnknown(err error) bool {
switch err {
case context.DeadlineExceeded:
return false
default:
return true
}

View File

@@ -9,6 +9,7 @@ import (
)
func TestAccept(t *testing.T) {
tests := []struct {
name string
err error