return the current backoff
return true if this is BackoffStrategy.empty, when true, calling
duration will return a NoSuchElementException, calling next
will return an UnsupportedOperationException.
return true if this is BackoffStrategy.empty, when true, calling
duration will return a NoSuchElementException, calling next
will return an UnsupportedOperationException. This is used to
terminate backoff supplies.
return a new BackoffStrategy to get the next backoff
Start creating backoffs from that once the current BackoffStrategy
isExhausted.
Start creating backoffs from that once the current BackoffStrategy
isExhausted. You can combine one or more BackoffStrategys by:
BackoffStrategy.const(1.second).take(5) .concat(BackoffStrategy.linear(2.millis, 1.millis).take(7)) .concat(BackoffStrategy.const(9.millis))
The BackoffStrategys are invoked in the same order as they are concatenated. The former BackoffStrategy needs to be finite in order to invoke the succeeding strategies.
take on how to create a finite BackoffStrategy.
Only create backoffs for attempt number of times.
Only create backoffs for attempt number of times. When attempt
is reached, a BackoffStrategy.empty will be returned.
take(0) will return a BackoffStrategy.empty, where
calling duration and next will throw exceptions.
A recursive ADT to define various backoff strategies, where
durationreturns the current backoff, andnextreturns a new BackoffStrategy.All BackoffStrategys are infinite unless it isExhausted (an empty BackoffStrategy), in this case, calling
durationwill return a NoSuchElementException, callingnextwill return an UnsupportedOperationException.Finagle provides the following backoff strategies:
1. BackoffFunction - create backoffs based on a given function, can be created via
BackoffStrategy.apply. 2. BackoffFromGeneration - create backoffs based on a generation function, can be created viaBackoffStrategy.fromFunction. 3. Const - return a constant backoff, can be created viaBackoffStrategy.const. 4. Exponential - create backoffs that grow exponentially, can be created viaBackoffStrategy.exponential. 5. Linear - create backoffs that grow linearly, can be created viaBackoffStrategy.linear. 6. DecorrelatedJittered - create backoffs that jitter randomly between a start value and 3 times of that value, can be created viaBackoffStrategy.decorrelatedJittered. 7. EqualJittered - create backoffs that jitter between 0 and half of the exponential growth. Can be created viaBackoffStrategy.equalJittered. 8. ExponentialJittered - create backoffs that jitter randomly between 0 and a value that grows exponentially by 2. Can be created viaBackoffStrategy.exponentialJittered.If the backoff returned from any BackoffStrategys overflowed, all succeeding backoffs will be Duration.Top.
,You can combine one or more BackoffStrategys with take(Int) and concat(BackoffStrategy).
,All BackoffStrategys are infinite unless using take(Int) to create a strategy with limited number of iterations.
,None of the BackoffStrategys is memoized, for strategies that involve randomness (
,DecorrelatedJittered,EqualJitteredandExponentialJittered), there is no way to foresee the next backoff value.A new BackoffStrategy will be created only when
nextis called.