Lifts a function of type A => Option[(Duration, RetryPolicy[A])] in the RetryPolicy
type.
Retry based on a series of backoffs defined by a Stream[Duration]
.
Retry based on a series of backoffs defined by a Stream[Duration]
. The
stream is consulted to determine the duration after which a request is to
be retried. A PartialFunction
argument determines which request types
are retryable.
A constructor usable from Java (backoffs
from Backoff.toJava
).
Combines multiple RetryPolicy
s into a single combined RetryPolicy
, with interleaved
backoffs.
Combines multiple RetryPolicy
s into a single combined RetryPolicy
, with interleaved
backoffs. For a given value of A
, each policy in policies
is tried in order. If all
policies return None
, then the combined RetryPolicy
returns None
. If policy P
returns
Some((D, P'))
, then the combined RetryPolicy
returns Some((D, P))
is a
new combined , where
PRetryPolicy
with the same sub-policies, with the exception of P
replaced by
P'
.
The ordering of policies matters: earlier policies get a chance to handle the failure before later policies; a catch-all policy, if any, should be last.
As an example, let's say you combine two RetryPolicy
s, R1
and R2
, where R1
handles
only exception E1
with a backoff of (10.milliseconds, 20.milliseconds, 30.milliseconds)
,
while R2
handles only exception E2
with a backoff of (15.milliseconds, 25.milliseconds)
.
If a sequence of exceptions, (E2, E1, E1, E2)
, is fed in order to the combined retry policy,
the backoffs seen will be (15.milliseconds, 10.milliseconds, 20.milliseconds,
25.milliseconds)
.
The maximum number of retries the combined policy could allow under the worst case scenario
of exceptions is equal to the sum of the individual maximum retries of each subpolicy. To
put a cap on the combined maximum number of retries, you can call limit
on the combined
policy with a smaller cap.
Retry a specific number of times on WriteExceptions.
Retry a specific number of times.
Retry a specific number of times. A PartialFunction
argument determines
which request types are retryable.