trait Retry[-E, +A] extends AnyRef
A stateful policy for retrying IO actions. See IO.retry.
A Retry[E, A] value can handle errors of type E, and produces a value of
type A at every step. Retry[E, A] forms an applicative on the value,
allowing rich composition of different retry policies.
Retry policies also compose each of the following ways:
1. Intersection, using the && operator, which requires that both policies
agree to retry, using the longer of the two durations between retries.
2. Union, using the || operator, which requires that only one policy
agrees to retry, using the shorter of the two durations between retries.
3. Sequence, using the <||> operator, which applies the first policy
until it fails, and then switches over to the second policy.
- Self Type
- Retry[E, A]
- Alphabetic
- By Inheritance
- Retry
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
abstract
type
State
The full type of state used by the retry policy, including hidden state not exposed via the
Atype parameter.
Abstract Value Members
-
abstract
val
initial: IO[Nothing, State]
The initial state of the policy.
The initial state of the policy. This can be an effect, such as
nanoTime. -
abstract
def
update(e: E, s: State): IO[Nothing, Decision[State]]
Invoked on an error.
Invoked on an error. This method can return the next state, which will continue the retry process, or it can return a failure, which will terminate the retry.
-
abstract
def
value(state: State): A
Extracts the value of this policy from the state.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
&&[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]
Returns a new policy that retries for as long as this policy and the specified policy both agree to retry, using the longer of the two durations between retries.
Returns a new policy that retries for as long as this policy and the specified policy both agree to retry, using the longer of the two durations between retries.
For pure policies (which have deterministic initial states/updates), the following laws holds:
io.retryWith(r && never).void === io.retryWith(never) io.retryWith(r && r).void === io.retryWith(r).void io.retryWith(r1 && r2).map(t => (t._2, t._1)) === io.retryWith(r2 && r1) -
final
def
*>[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, A2]
The same as
&&, but discards the right hand state. -
final
def
<*[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, A]
The same as
&&, but discards the left hand state. -
final
def
<>[E2 <: E, A2 >: A](that: ⇒ Retry[E2, A2]): Retry[E2, A2]
Same as
<||>, but merges the states. -
final
def
<||>[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, Either[A, A2]]
Returns a new policy that first tries this policy, and if it fails, then switches over to the specified policy.
Returns a new policy that first tries this policy, and if it fails, then switches over to the specified policy. The returned policy is maximally lazy, not computing the initial state of the alternate policy until when and if this policy fails.
io.retryWith(Retry.never <> r.void) === io.retryWith(r) io.retryWith(r.void <> Retry.never) === io.retryWith(r)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
andThen[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, Either[A, A2]]
A named version of the
<||>operator. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final
def
both[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]
A named alias for
&&. -
final
def
bothWith[E2 <: E, A2, A3](that: ⇒ Retry[E2, A2])(f: (A, A2) ⇒ A3): Retry[E2, A3]
The same as
bothfollowed bymap. -
final
def
check[E1 <: E, B](action: (E1, A) ⇒ IO[Nothing, B])(pred: (B) ⇒ Boolean): Retry[E1, A]
Peeks at the value produced by this policy, executes some action, and then continues retrying or not based on the specified value predicate.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
const[A2](a2: A2): Retry[E, A2]
Returns a new retry policy that always produces the constant state.
-
final
def
contramap[E2](f: (E2) ⇒ E): Retry[E2, A]
Returns a new retry policy with the capability to handle a narrower class of errors
E2. -
final
def
delayed(f: (Duration) ⇒ Duration): Retry[E, A]
Delays the retry policy by the specified amount.
-
final
def
either[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]
A named alias for
||. -
final
def
eitherWith[E2 <: E, A2, A3](that: ⇒ Retry[E2, A2])(f: (A, A2) ⇒ A3): Retry[E2, A3]
The same as
eitherfollowed bymap. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.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
-
final
def
jittered(min: Double, max: Double): Retry[E, A]
Applies random jitter to the retry policy bounded by the specified factors.
-
final
def
jittered: Retry[E, A]
Applies random jitter to the retry policy bounded by the factors 0.0 and 1.0.
-
final
def
map[A2](f: (A) ⇒ A2): Retry[E, A2]
Returns a new retry policy with the value transformed by the specified function.
-
final
def
modifyDelay[E2 <: E](f: (E2, A, Duration) ⇒ IO[Nothing, Duration]): Retry[E2, A]
Modifies the delay of this retry policy by applying the specified effectful function to the error, state, and current delay.
-
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
onDecision[E2 <: E](f: (E2, Decision[A]) ⇒ IO[Nothing, Unit]): Retry[E2, A]
A new policy that applies the current one but runs the specified effect for every decision of this policy.
A new policy that applies the current one but runs the specified effect for every decision of this policy. This can be used to create retry policies that log failures, decisions, or computed values.
-
final
def
reconsider[E2 <: E](f: (E2, Decision[A]) ⇒ IO[Nothing, Decision[Unit]]): Retry[E2, A]
Modifies the duration and retry/no-retry status of this policy.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
unary_!: Retry[E, A]
Negates this policy, returning failures for successes, and successes for failures.
-
final
def
untilError[E1 <: E](p: (E1) ⇒ Boolean): Retry[E1, A]
Returns a new policy that retries until the error matches the condition.
- final def untilValue(p: (A) ⇒ Boolean): Retry[E, A]
-
final
def
void: Retry[E, Unit]
Returns a new retry policy that always produces unit state.
-
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
- @native() @throws( ... )
-
final
def
whileError[E1 <: E](p: (E1) ⇒ Boolean): Retry[E1, A]
Returns a new policy that retries while the error matches the condition.
- final def whileValue(p: (A) ⇒ Boolean): Retry[E, A]
-
final
def
||[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]
Returns a new policy that retries for as long as either this policy or the specified policy want to retry, using the shorter of the two durations.
Returns a new policy that retries for as long as either this policy or the specified policy want to retry, using the shorter of the two durations.
For pure policies (which have deterministic initial states/updates), the following laws holds:
io.retryWith(r || always).void === io.retryWith(r) io.retryWith(r || r).void === io.retryWith(r).void io.retryWith(r1 || r2).map(t => (t._2, t._1)) === io.retryWith(r2 || r1)