go-zero/zrpc/internal/codes/accept.go
2021-03-01 23:52:44 +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
}
}