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

Unified Diff: common/retry/transient.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/retry/transient.go
diff --git a/common/retry/transient.go b/common/retry/transient.go
deleted file mode 100644
index fa641d446df9574cf752afbed012b4e1a08eb44a..0000000000000000000000000000000000000000
--- a/common/retry/transient.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2015 The LUCI Authors. All rights reserved.
-// Use of this source code is governed under the Apache License, Version 2.0
-// that can be found in the LICENSE file.
-
-package retry
-
-import (
- "time"
-
- "github.com/luci/luci-go/common/errors"
- "golang.org/x/net/context"
-)
-
-// transientOnlyIterator is an Iterator implementation that only retries errors
-// if they are transient.
-//
-// (See errors.IsTransient).
-type transientOnlyIterator struct {
- Iterator // The wrapped Iterator.
-}
-
-func (i *transientOnlyIterator) Next(ctx context.Context, err error) time.Duration {
- if !errors.IsTransient(err) {
- return Stop
- }
- return i.Iterator.Next(ctx, err)
-}
-
-// TransientOnly returns an Iterator that wraps another Iterator. It will fall
-// through to the wrapped Iterator if a transient error is encountered;
-// otherwise, it will not retry.
-// Returns nil if f is nil.
-func TransientOnly(f Factory) Factory {
- if f == nil {
- return nil
- }
- return wrap(f, func(it Iterator) Iterator {
- return &transientOnlyIterator{it}
- })
-}

Powered by Google App Engine
This is Rietveld 408576698