Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 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 func TransientOnly(i Iterator) Iterator { | 32 func TransientOnly(i Iterator) Iterator { |
| 33 if i == nil { | 33 if i == nil { |
| 34 return nil | 34 return nil |
| 35 } | 35 } |
| 36 return &transientOnlyIterator{i} | 36 return &transientOnlyIterator{i} |
| 37 } | 37 } |
| 38 | |
| 39 // TransientOnlyGenerator wraps a retry.Generator, retrying only in the event | |
| 40 // of Transient errors. | |
| 41 func TransientOnlyGenerator(gen Generator) Generator { | |
|
dnj (Google)
2016/01/21 04:36:24
Now that we have the concept of a generator, we ca
| |
| 42 return func() Iterator { | |
| 43 return TransientOnly(gen()) | |
| 44 } | |
| 45 } | |
| OLD | NEW |