| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 ///<reference path="../luci-sleep-promise/promise.ts" /> | 7 ///<reference path="../luci-sleep-promise/promise.ts" /> |
| 8 | 8 |
| 9 namespace luci { | 9 namespace luci { |
| 10 /** | 10 /** |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * RetryIterator configuration class. | 211 * RetryIterator configuration class. |
| 212 * | 212 * |
| 213 * A user will define the retry parameters using a Retry instance, then create | 213 * A user will define the retry parameters using a Retry instance, then create |
| 214 * a RetryIterator with them. | 214 * a RetryIterator with them. |
| 215 */ | 215 */ |
| 216 export type Retry = { | 216 export type Retry = { |
| 217 // The number of retries to perform before failing. If undefined, will retry | 217 // The number of retries to perform before failing. If undefined, will retry |
| 218 // indefinitely. | 218 // indefinitely. |
| 219 retries: number | undefined; | 219 retries?: number; |
| 220 | 220 |
| 221 // The amount of time to delay in between retry attempts, in milliseconds. | 221 // The amount of time to delay in between retry attempts, in milliseconds. |
| 222 // If undefined or < 0, no delay will be imposed. | 222 // If undefined or < 0, no delay will be imposed. |
| 223 delay: number; | 223 delay: number; |
| 224 // The maximum delay to apply, in milliseconds. If > 0 and delay scales past | 224 // The maximum delay to apply, in milliseconds. If > 0 and delay scales past |
| 225 // "maxDelay", it will be capped at "maxDelay". | 225 // "maxDelay", it will be capped at "maxDelay". |
| 226 maxDelay: number | undefined; | 226 maxDelay?: number; |
| 227 | 227 |
| 228 // delayScaling is the multiplier applied to "delay" in between retries. If | 228 // delayScaling is the multiplier applied to "delay" in between retries. If |
| 229 // undefined or <= 1, DEFAULT_DELAY_SCALING will be used. | 229 // undefined or <= 1, DEFAULT_DELAY_SCALING will be used. |
| 230 delayScaling?: number; | 230 delayScaling?: number; |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * Generic exponential backoff retry delay generator. | 234 * Generic exponential backoff retry delay generator. |
| 235 * | 235 * |
| 236 * A RetryIterator is a specific configured instance of a Retry. Each call to | 236 * A RetryIterator is a specific configured instance of a Retry. Each call to |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 let delay = this.delay; | 273 let delay = this.delay; |
| 274 this.delay *= this.delayScaling; | 274 this.delay *= this.delayScaling; |
| 275 if (this.maxDelay > 0 && delay > this.maxDelay) { | 275 if (this.maxDelay > 0 && delay > this.maxDelay) { |
| 276 this.delay = delay = this.maxDelay; | 276 this.delay = delay = this.maxDelay; |
| 277 } | 277 } |
| 278 return delay; | 278 return delay; |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 } | 281 } |
| OLD | NEW |