Class

com.twitter.finagle.service

BackoffStrategy

Related Doc: package service

Permalink

abstract class BackoffStrategy extends AnyRef

A recursive ADT to define various backoff strategies, where duration returns the current backoff, and next returns a new BackoffStrategy.

All BackoffStrategys are infinite unless it isExhausted (an empty BackoffStrategy), 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 BackoffStrategy.apply. 2. BackoffFromGeneration - create backoffs based on a generation function, can be created via BackoffStrategy.fromFunction. 3. Const - return a constant backoff, can be created via BackoffStrategy.const. 4. Exponential - create backoffs that grow exponentially, can be created via BackoffStrategy.exponential. 5. Linear - create backoffs that grow linearly, can be created via BackoffStrategy.linear. 6. DecorrelatedJittered - create backoffs that jitter randomly between a start value and 3 times of that value, can be created via BackoffStrategy.decorrelatedJittered. 7. EqualJittered - create backoffs that jitter between 0 and half of the exponential growth. Can be created via BackoffStrategy.equalJittered. 8. ExponentialJittered - create backoffs that jitter randomly between 0 and a value that grows exponentially by 2. Can be created via BackoffStrategy.exponentialJittered.

Note

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, EqualJittered and ExponentialJittered), there is no way to foresee the next backoff value.

,

A new BackoffStrategy will be created only when next is called.

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

Instance Constructors

  1. new BackoffStrategy()

    Permalink

Abstract Value Members

  1. abstract def duration: Duration

    Permalink

    return the current backoff

  2. abstract def isExhausted: Boolean

    Permalink

    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.

  3. abstract def next: BackoffStrategy

    Permalink

    return a new BackoffStrategy to get the next backoff

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def concat(that: BackoffStrategy): BackoffStrategy

    Permalink

    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))
    Note

    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.

    See also

    take on how to create a finite BackoffStrategy.

  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  17. def take(attempt: Int): BackoffStrategy

    Permalink

    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.

    Note

    take(0) will return a BackoffStrategy.empty, where calling duration and next will throw exceptions.

  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped