Skip to content

Commit

Permalink
Convert more HTTP statuses to GRPC statuses. (#279)
Browse files Browse the repository at this point in the history
409 conflict should be GRPC status already exists.

502 bad gateway should be GRPC status unavailable so that we retry.
  • Loading branch information
ggreer authored Dec 31, 2024
1 parent 0f7435f commit 4fe86e6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/uhttp/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,16 @@ func (c *BaseHttpClient) Do(req *http.Request, options ...DoOption) (*http.Respo
switch resp.StatusCode {
case http.StatusRequestTimeout:
return resp, WrapErrorsWithRateLimitInfo(codes.DeadlineExceeded, resp, optErrs...)
case http.StatusTooManyRequests, http.StatusServiceUnavailable:
case http.StatusTooManyRequests, http.StatusBadGateway, http.StatusServiceUnavailable:
return resp, WrapErrorsWithRateLimitInfo(codes.Unavailable, resp, optErrs...)
case http.StatusNotFound:
return resp, WrapErrorsWithRateLimitInfo(codes.NotFound, resp, optErrs...)
case http.StatusUnauthorized:
return resp, WrapErrorsWithRateLimitInfo(codes.Unauthenticated, resp, optErrs...)
case http.StatusForbidden:
return resp, WrapErrorsWithRateLimitInfo(codes.PermissionDenied, resp, optErrs...)
case http.StatusConflict:
return resp, WrapErrorsWithRateLimitInfo(codes.AlreadyExists, resp, optErrs...)
case http.StatusNotImplemented:
return resp, WrapErrorsWithRateLimitInfo(codes.Unimplemented, resp, optErrs...)
}
Expand Down

0 comments on commit 4fe86e6

Please sign in to comment.