Packages

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:

1. BackoffFunction - create backoffs based on a given function, can be created via Backoff.apply. 2. BackoffFromGeneration - create backoffs based on a generation function, can be created via Backoff.fromFunction. 3. Const - return a constant backoff, can be created via Backoff.const. 4. Exponential - create backoffs that grow exponentially, can be created via Backoff.exponential. 5. Linear - create backoffs that grow linearly, can be created via Backoff.linear. 6. DecorrelatedJittered - create backoffs that jitter randomly between a start value and 3 times of that value, can be created via Backoff.decorrelatedJittered. 7. EqualJittered - create backoffs that jitter between 0 and half of the exponential growth. Can be created via Backoff.equalJittered. 8. ExponentialJittered - create backoffs that jitter randomly between 0 and a value that grows exponentially by 2. Can be created via Backoff.exponentialJittered.

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 and ExponentialJittered), 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.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Backoff
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def duration: Duration

    return the current backoff

  2. 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.

  3. abstract def next: Backoff

    return a new Backoff to get the next backoff

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ++(that: Backoff): Backoff

    An alias for Backoff concatenation.

  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. 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))
    Note

    The Backoffs are invoked in the same order as they are concatenated. The former Backoff needs to be finite in order to invoke the succeeding strategies.

    See also

    take on how to create a finite Backoff.

  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  18. final def take(attempt: Int): Backoff

    Only create backoffs for attempt number of times.

    Only create backoffs for attempt number of times. When attempt is reached, a Backoff.empty will be returned.

    Note

    Calling take with a non-positive attempt will return a Backoff.empty, where calling duration and next will throw exceptions.

  19. 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. When maxCumulativeBackoff is reached, a Backoff.empty will be returned.

    Note

    Calling takeUntil with a non-positive maxCumulativeBackoff will return a Backoff.empty, where calling duration and next will throw exceptions.

  20. final def toJavaIterator: Iterator[Duration]

    Convert a Backoff into a Java-friendly representation of iterator.

  21. final def toStream: Stream[Duration]

    Convert the Backoff to a Stream[Duration]

    Convert the Backoff to a Stream[Duration]

    Note

    This API is only recommended to be used for migrating from Stream to Backoff.

    ,

    Every element of the returned Stream will be memorized due to the nature of Stream, when using this method, your service is at risk of memory leaks.

  22. def toString(): String
    Definition Classes
    Backoff → AnyRef → Any
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped