| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package retry | 5 package retry |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "time" | 8 "time" |
| 9 | 9 |
| 10 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 func (i *transientOnlyIterator) Next(ctx context.Context, err error) time.Durati
on { | 22 func (i *transientOnlyIterator) Next(ctx context.Context, err error) time.Durati
on { |
| 23 if !errors.IsTransient(err) { | 23 if !errors.IsTransient(err) { |
| 24 return Stop | 24 return Stop |
| 25 } | 25 } |
| 26 return i.Iterator.Next(ctx, err) | 26 return i.Iterator.Next(ctx, err) |
| 27 } | 27 } |
| 28 | 28 |
| 29 // TransientOnly returns an Iterator that wraps another Iterator. It will fall | 29 // TransientOnly returns an Iterator that wraps another Iterator. It will fall |
| 30 // through to the wrapped Iterator if a transient error is encountered; | 30 // through to the wrapped Iterator if a transient error is encountered; |
| 31 // otherwise, it will not retry. | 31 // otherwise, it will not retry. |
| 32 // Returns nil if f is nil. |
| 32 func TransientOnly(f Factory) Factory { | 33 func TransientOnly(f Factory) Factory { |
| 34 if f == nil { |
| 35 return nil |
| 36 } |
| 33 return wrap(f, func(it Iterator) Iterator { | 37 return wrap(f, func(it Iterator) Iterator { |
| 34 return &transientOnlyIterator{it} | 38 return &transientOnlyIterator{it} |
| 35 }) | 39 }) |
| 36 } | 40 } |
| OLD | NEW |