feat: convert grpc errors to http status codes (#1997)
* feat: convert grpc errors to http status codes * chore: circuit break include unimplemented grpc error * chore: add reference link in comments
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
// 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:
|
||||
case codes.DeadlineExceeded, codes.Internal, codes.Unavailable, codes.DataLoss, codes.Unimplemented:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
|
||||
@@ -49,7 +49,6 @@ func UnaryTimeoutInterceptor(timeout time.Duration) grpc.UnaryServerInterceptor
|
||||
return resp, err
|
||||
case <-ctx.Done():
|
||||
err := ctx.Err()
|
||||
|
||||
if err == context.Canceled {
|
||||
err = status.Error(codes.Canceled, err.Error())
|
||||
} else if err == context.DeadlineExceeded {
|
||||
|
||||
Reference in New Issue
Block a user