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

Unified Diff: common/gcloud/gs/gs.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: common/gcloud/gs/gs.go
diff --git a/common/gcloud/gs/gs.go b/common/gcloud/gs/gs.go
index 4ed0dde7b9784976b9aa1fce4dcff98b647df20d..11548d74d09da76d931fb3dfc76ec812f69d717d 100644
--- a/common/gcloud/gs/gs.go
+++ b/common/gcloud/gs/gs.go
@@ -13,6 +13,7 @@ import (
"github.com/luci/luci-go/common/errors"
log "github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/common/retry"
+ "github.com/luci/luci-go/common/retry/transient"
gs "cloud.google.com/go/storage"
"golang.org/x/net/context"
@@ -132,7 +133,7 @@ func (c *prodClient) Rename(src, dst Path) error {
}
// First stage: CopyTo
- err = retry.Retry(c, retry.TransientOnly(retry.Default), func() error {
+ err = retry.Retry(c, transient.Only(retry.Default), func() error {
if _, err := dstObj.CopierFrom(srcObj).Run(c); err != nil {
// The storage library doesn't return gs.ErrObjectNotExist when Delete
// returns a 404. Catch that explicitly.
@@ -141,7 +142,7 @@ func (c *prodClient) Rename(src, dst Path) error {
}
// Assume all unexpected errors are transient.
- return errors.WrapTransient(err)
+ return transient.Tag.Apply(err)
}
return nil
}, func(err error, d time.Duration) {
@@ -176,7 +177,7 @@ func (c *prodClient) Delete(p Path) error {
}
func (c *prodClient) deleteObject(o *gs.ObjectHandle) error {
- return retry.Retry(c, retry.TransientOnly(retry.Default), func() error {
+ return retry.Retry(c, transient.Only(retry.Default), func() error {
if err := o.Delete(c); err != nil {
// The storage library doesn't return gs.ErrObjectNotExist when Delete
// returns a 404. Catch that explicitly.
@@ -186,7 +187,7 @@ func (c *prodClient) deleteObject(o *gs.ObjectHandle) error {
}
// Assume all unexpected errors are transient.
- return errors.WrapTransient(err)
+ return transient.Tag.Apply(err)
}
return nil
}, func(err error, d time.Duration) {

Powered by Google App Engine
This is Rietveld 408576698