abstract class RetryPolicy[-A] extends (A) ⇒ Option[(Duration, RetryPolicy[A])]
A function defining retry behavior for a given value type A
.
The Function1 returns None if no more retries should be made
and Some if another retry should happen. The returned Some
has
a Duration field for how long to wait for the next retry as well
as the next RetryPolicy
to use.
Finagle will automatically handle retryable Throws. Requests that have not been written to or processed by a remote service are safe to retry.
- See also
SimpleRetryPolicy for a Java friendly API.
- Alphabetic
- By Inheritance
- RetryPolicy
- Function1
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new RetryPolicy()
Abstract Value Members
-
abstract
def
apply(v1: A): Option[(Duration, RetryPolicy[A])]
- Definition Classes
- Function1
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
andThen[A](g: (Option[(Duration, RetryPolicy[A])]) ⇒ A): (A) ⇒ A
- Definition Classes
- Function1
- Annotations
- @unspecialized()
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
compose[A](g: (A) ⇒ A): (A) ⇒ Option[(Duration, RetryPolicy[A])]
- Definition Classes
- Function1
- Annotations
- @unspecialized()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
filter[B <: A](pred: (B) ⇒ Boolean): RetryPolicy[B]
Creates a new
RetryPolicy
based on the currentRetryPolicy
in which values ofA
are first checked against a predicate function, and only if the predicate returns true will the value be passed on to the currentRetryPolicy
.Creates a new
RetryPolicy
based on the currentRetryPolicy
in which values ofA
are first checked against a predicate function, and only if the predicate returns true will the value be passed on to the currentRetryPolicy
.The predicate function need not be a pure function, but can change its behavior over time. For example, the predicate function's decision can be based upon backpressure signals supplied by things like failure rates or latency, which allows
RetryPolicy
s to dynamically reduce the number of retries in response to backpressure.The predicate function is only called on the first failure in a chain. Any additional chained RetryPolicies returned by the current policy will then see additional failures unfiltered. Contrast this will
filterEach
, which applies the filter to eachRetryPolicy
in the chain. -
def
filterEach[B <: A](pred: (B) ⇒ Boolean): RetryPolicy[B]
Similar to
filter
, but the predicate is applied to eachRetryPolicy
in the chain returned by the current RetryPolicy.Similar to
filter
, but the predicate is applied to eachRetryPolicy
in the chain returned by the current RetryPolicy. For example, if the currentRetryPolicy
returnsSome((D, P'))
for valueE
(of typeA
), and the given predicate returns true forE
, then the value returned from the filteringRetryPolicy
will beSome((D, P))
where
P
is equal to
P'.filterEach(pred).
One example where this is useful is to dynamically and fractionally allow retries based upon backpressure signals. If, for example, the predicate function returned true or false based upon a probability distribution computed from a backpressure signal, it could return true 50% of the time, giving you a 50% chance of performing a single retry, a 25% chance of performing 2 retries, 12.5% chance of performing 3 retries, etc. This might be more desirable than just using
filter
where you end up with a 50% chance of no retries and 50% chance of the full number of retries. -
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
limit(maxRetries: ⇒ Int): RetryPolicy[A]
Applies a dynamically chosen retry limit to an existing
RetryPolicy
that may allow for more retries.Applies a dynamically chosen retry limit to an existing
RetryPolicy
that may allow for more retries. When the returnedRetryPolicy
is first invoked, it will call themaxRetries
by-name parameter to get the current maximum retries allowed. Regardless of the number of retries that the underlying policy would allow, it is capped to be no greater than the number returned bymaxRetries
on the first failure in the chain.Using a dynamically chosen retry limit allows for the retry count to be tuned at runtime based upon backpressure signals such as failure rate or request latency.
-
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
-
def
toString(): String
- Definition Classes
- RetryPolicy → Function1 → AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()