go-zero/zrpc/internal/codes/accept.go
chenquan dfb3cb510a
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
2021-08-28 12:07:14 +08:00

17 lines
329 B
Go

package codes
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// Acceptable checks if given error is acceptable.
func Acceptable(err error) bool {
switch status.Code(err) {
case codes.DeadlineExceeded, codes.Internal, codes.Unavailable, codes.DataLoss:
return false
default:
return true
}
}