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

Unified Diff: grpc/prpc/client.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor Created 3 years, 6 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
Index: grpc/prpc/client.go
diff --git a/grpc/prpc/client.go b/grpc/prpc/client.go
index ff6b68bbad95d5465b463491d7841d5c18779d5b..971a8c01f6bae1d62769616e0c2aa11a7e234b92 100644
--- a/grpc/prpc/client.go
+++ b/grpc/prpc/client.go
@@ -26,6 +26,7 @@ import (
"github.com/luci/luci-go/common/errors"
"github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/common/retry"
+ "github.com/luci/luci-go/common/retry/transient"
"github.com/luci/luci-go/grpc/grpcutil"
)
@@ -153,7 +154,7 @@ func (c *Client) CallRaw(ctx context.Context, serviceName, methodName string, in
var contentType string
err = retry.Retry(
ctx,
- retry.TransientOnly(options.Retry),
+ transient.Only(options.Retry),
func() error {
ctx := ctx
logging.Debugf(ctx, "RPC %s/%s.%s", c.Host, serviceName, methodName)
@@ -203,7 +204,8 @@ func (c *Client) CallRaw(ctx context.Context, serviceName, methodName string, in
}
if err != nil {
// Treat all errors here as transient.
- return errors.WrapTransient(fmt.Errorf("failed to send request: %s", err))
+ return errors.Annotate(err).Reason("failed to send request").
+ Tag(transient.Tag).Err()
}
if options.resHeaderMetadata != nil {
@@ -266,7 +268,7 @@ func (c *Client) CallRaw(ctx context.Context, serviceName, methodName string, in
// AppEngine), and should be automatically retried even if a gRPC code
// header is not supplied.
if res.StatusCode >= http.StatusInternalServerError {
- err = errors.WrapTransient(err)
+ err = transient.Tag.Apply(err)
}
return err
}
@@ -282,7 +284,7 @@ func (c *Client) CallRaw(ctx context.Context, serviceName, methodName string, in
desc := strings.TrimSuffix(buf.String(), "\n")
err := grpcutil.Errf(code, "%s", desc)
if grpcutil.IsTransientCode(code) {
- err = errors.WrapTransient(err)
+ err = transient.Tag.Apply(err)
}
return err
}
« grpc/grpcutil/errors.go ('K') | « grpc/grpcutil/errors.go ('k') | grpc/prpc/client_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698