Packages

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]
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Retry
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type State

    The full type of state used by the retry policy, including hidden state not exposed via the A type parameter.

Abstract Value Members

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

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

  3. abstract def value(state: State): A

    Extracts the value of this policy from the state.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. 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)
  4. final def *>[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, A2]

    The same as &&, but discards the right hand state.

  5. final def <*[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, A]

    The same as &&, but discards the left hand state.

  6. final def <>[E2 <: E, A2 >: A](that: ⇒ Retry[E2, A2]): Retry[E2, A2]

    Same as <||>, but merges the states.

  7. 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)
  8. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. final def andThen[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, Either[A, A2]]

    A named version of the <||> operator.

  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. final def both[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]

    A named alias for &&.

  12. final def bothWith[E2 <: E, A2, A3](that: ⇒ Retry[E2, A2])(f: (A, A2) ⇒ A3): Retry[E2, A3]

    The same as both followed by map.

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

  14. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  15. final def const[A2](a2: A2): Retry[E, A2]

    Returns a new retry policy that always produces the constant state.

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

  17. final def delayed(f: (Duration) ⇒ Duration): Retry[E, A]

    Delays the retry policy by the specified amount.

  18. final def either[E2 <: E, A2](that: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]

    A named alias for ||.

  19. final def eitherWith[E2 <: E, A2, A3](that: ⇒ Retry[E2, A2])(f: (A, A2) ⇒ A3): Retry[E2, A3]

    The same as either followed by map.

  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  22. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. final def jittered(min: Double, max: Double): Retry[E, A]

    Applies random jitter to the retry policy bounded by the specified factors.

  27. final def jittered: Retry[E, A]

    Applies random jitter to the retry policy bounded by the factors 0.0 and 1.0.

  28. final def map[A2](f: (A) ⇒ A2): Retry[E, A2]

    Returns a new retry policy with the value transformed by the specified function.

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

  30. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  31. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  32. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. 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.

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

  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. def unary_!: Retry[E, A]

    Negates this policy, returning failures for successes, and successes for failures.

  38. final def untilError[E1 <: E](p: (E1) ⇒ Boolean): Retry[E1, A]

    Returns a new policy that retries until the error matches the condition.

  39. final def untilValue(p: (A) ⇒ Boolean): Retry[E, A]
  40. final def void: Retry[E, Unit]

    Returns a new retry policy that always produces unit state.

  41. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  44. final def whileError[E1 <: E](p: (E1) ⇒ Boolean): Retry[E1, A]

    Returns a new policy that retries while the error matches the condition.

  45. final def whileValue(p: (A) ⇒ Boolean): Retry[E, A]
  46. 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)

Inherited from AnyRef

Inherited from Any

Ungrouped