sealed abstract class Backoff extends AnyRef
A recursive ADT to define various backoff strategies, where duration
returns the current backoff, and next
returns a new Backoff.
All Backoffs are infinite unless it isExhausted (an empty
Backoff), in this case, calling duration
will return a
NoSuchElementException, calling next
will return an
UnsupportedOperationException.
Finagle provides the following backoff strategies:
- BackoffFunction
- Create backoffs based on a given function, can be created via
Backoff.apply
.
- Create backoffs based on a given function, can be created via
- BackoffFromGeneration
- Create backoffs based on a generation function, can be created via
Backoff.fromFunction
.
- Create backoffs based on a generation function, can be created via
- Const
- Return a constant backoff, can be created via
Backoff.const
.
- Return a constant backoff, can be created via
- Exponential
- Create backoffs that grow exponentially, can be created via
Backoff.exponential
.
- Create backoffs that grow exponentially, can be created via
- Linear
- Create backoffs that grow linearly, can be created via
Backoff.linear
.
- Create backoffs that grow linearly, can be created via
- DecorrelatedJittered
- Create backoffs that jitter randomly between a start value and 3 times of that value, can be created via
Backoff.decorrelatedJittered
.
- Create backoffs that jitter randomly between a start value and 3 times of that value, can be created via
- EqualJittered
- Create backoffs that jitter between 0 and half of the exponential growth. Can be created via
Backoff.equalJittered
.
- Create backoffs that jitter between 0 and half of the exponential growth. Can be created via
- ExponentialJittered
- Create backoffs that jitter randomly between 0 and a value that grows exponentially by 2. Can be created via
Backoff.exponentialJittered
.
- Create backoffs that jitter randomly between 0 and a value that grows exponentially by 2. Can be created via
- Note
A new Backoff will be created only when
,next
is called.None of the Backoffs are memoized, for strategies that involve randomness (
,DecorrelatedJittered
,EqualJittered
andExponentialJittered
), there is no way to foresee the next backoff value.All Backoffs are infinite unless using take(Int) to create a strategy with limited number of iterations.
,You can combine one or more Backoffs with take(Int) and concat(Backoff).
,If the backoff returned from any Backoffs overflowed, all succeeding backoffs will be Duration.Top.
- Alphabetic
- By Inheritance
- Backoff
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def duration: Duration
return the current backoff
- abstract def isExhausted: Boolean
return true if this is Backoff.empty, when true, calling duration will return a NoSuchElementException, calling
next
will return an UnsupportedOperationException.return true if this is Backoff.empty, when true, calling duration will return a NoSuchElementException, calling
next
will return an UnsupportedOperationException. This is used to terminate backoff supplies. - abstract def next: Backoff
return a new Backoff to get the next backoff
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ++(that: Backoff): Backoff
An alias for Backoff concatenation.
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def concat(that: Backoff): Backoff
Start creating backoffs from
that
once the current Backoff isExhausted.Start creating backoffs from
that
once the current Backoff isExhausted. You can combine one or more Backoffs by:Backoff.const(1.second).take(5) .concat(Backoff.linear(2.millis, 1.millis).take(7)) .concat(Backoff.const(9.millis))
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def take(attempt: Int): Backoff
Only create backoffs for
attempt
number of times.Only create backoffs for
attempt
number of times. Whenattempt
is reached, a Backoff.empty will be returned.- Note
Calling take with a non-positive
attempt
will return a Backoff.empty, where callingduration
andnext
will throw exceptions.
- final def takeUntil(maxCumulativeBackoff: Duration): Backoff
Only create backoffs until the sum of all previous backoffs is less than or equal to
maxCumulativeBackoff
.Only create backoffs until the sum of all previous backoffs is less than or equal to
maxCumulativeBackoff
. WhenmaxCumulativeBackoff
is reached, a Backoff.empty will be returned.- Note
Calling takeUntil with a non-positive
maxCumulativeBackoff
will return a Backoff.empty, where callingduration
andnext
will throw exceptions.
- final def toJavaIterator: Iterator[Duration]
Convert a Backoff into a Java-friendly representation of iterator.
- final def toStream: Stream[Duration]
Convert the Backoff to a Stream[Duration]
- def toString(): String
- Definition Classes
- Backoff → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()