accept.go 329 B

12345678910111213141516
  1. package codes
  2. import (
  3. "google.golang.org/grpc/codes"
  4. "google.golang.org/grpc/status"
  5. )
  6. // Acceptable checks if given error is acceptable.
  7. func Acceptable(err error) bool {
  8. switch status.Code(err) {
  9. case codes.DeadlineExceeded, codes.Internal, codes.Unavailable, codes.DataLoss:
  10. return false
  11. default:
  12. return true
  13. }
  14. }