Trait/Object

scalaz.zio

Retry

Related Docs: object Retry | package zio

Permalink

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

    Permalink

    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]

    Permalink

    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]]

    Permalink

    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

    Permalink

    Extracts the value of this policy from the state.

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 &&[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]

    Permalink

    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]

    Permalink

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

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

    Permalink

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

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

    Permalink

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

  7. final def <||>[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, Either[A, A2]]

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef → Any
  9. final def andThen[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, Either[A, A2]]

    Permalink

    A named version of the <||> operator.

  10. final def asInstanceOf[T0]: T0

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

    Permalink

    A named alias for &&.

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

    Permalink

    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]

    Permalink

    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

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

    Permalink

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

  16. final def contramap[E2](f: (E2) ⇒ E): Retry[E2, A]

    Permalink

    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]

    Permalink

    Delays the retry policy by the specified amount.

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

    Permalink

    A named alias for ||.

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

    Permalink

    The same as either followed by map.

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

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

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

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

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

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

    Permalink
    Definition Classes
    Any
  26. final def jittered(min: Double, max: Double): Retry[E, A]

    Permalink

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

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

    Permalink

    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]

    Permalink

    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]

    Permalink

    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

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

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

    Permalink
    Definition Classes
    AnyRef
  33. final def onDecision[E2 <: E](f: (E2, Decision[A]) ⇒ IO[Nothing, Unit]): Retry[E2, A]

    Permalink

    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]

    Permalink

    Modifies the duration and retry/no-retry status of this policy.

  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  36. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  37. def unary_!: Retry[E, A]

    Permalink

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

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

    Permalink

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

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

    Permalink
  40. final def void: Retry[E, Unit]

    Permalink

    Returns a new retry policy that always produces unit state.

  41. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def whileError[E1 <: E](p: (E1) ⇒ Boolean): Retry[E1, A]

    Permalink

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

  45. final def whileValue(p: (A) ⇒ Boolean): Retry[E, A]

    Permalink
  46. final def ||[E2 <: E, A2](that0: ⇒ Retry[E2, A2]): Retry[E2, (A, A2)]

    Permalink

    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