Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1371)

Unified Diff: grpc/prpc/client.go

Issue 2360403002: pRPC: Retry on certain transient HTTP failures. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | grpc/prpc/client_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grpc/prpc/client.go
diff --git a/grpc/prpc/client.go b/grpc/prpc/client.go
index db6e000fa274b86f644138615208d851fbd643a9..cac2b7da70e4da2c3b983734917ad631b799f5ba 100644
--- a/grpc/prpc/client.go
+++ b/grpc/prpc/client.go
@@ -229,7 +229,16 @@ func (c *Client) CallRaw(ctx context.Context, serviceName, methodName string, in
if len(body) > bodySize {
body = body[:bodySize] + "..."
}
- return fmt.Errorf("HTTP %d: no gRPC code. Body: %q", res.StatusCode, body)
+ err := fmt.Errorf("HTTP %d: no gRPC code. Body: %q", res.StatusCode, body)
+
+ // Some HTTP codes are returned directly by hosting platforms (e.g.,
+ // AppEngine), and should be automatically retried even if a gRPC code
+ // header is not supplied.
+ switch res.StatusCode {
+ case http.StatusInternalServerError, http.StatusServiceUnavailable:
+ err = errors.WrapTransient(err)
+ }
+ return err
}
codeInt, err := strconv.Atoi(codeHeader)
« no previous file with comments | « no previous file | grpc/prpc/client_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698