Packages

final case class Backoff(logger: TracedLogger, flagCloseable: PerformUnlessClosing, maxRetries: Int, initialDelay: FiniteDuration, maxDelay: Duration, operationName: String, longDescription: String = "", actionable: Option[String] = None, retryLogLevel: Option[Level] = None, suspendRetries: Eval[FiniteDuration] = Eval.now(Duration.Zero))(implicit jitter: Jitter = Jitter.full(maxDelay)) extends RetryWithDelay with Product with Serializable

A retry policy which will back off using a configurable policy which incorporates random jitter. This has the advantage of reducing contention if you have threaded clients using the same service.

val policy = retry.Backoff()
val future = policy(issueRequest)

The following pre-made jitter algorithms are available for you to use:

You can choose one like this:

implicit val jitter = retry.Jitter.full(cap = 5.minutes)
val policy = retry.Backoff(1 second)
val future = policy(issueRequest)

If a jitter policy isn't in scope, it will use Jitter.full by default which tends to cause clients slightly less work at the cost of slightly more time.

For more information about the algorithms, see the following article:

https://www.awsarchitectureblog.com/2015/03/backoff.html

If the retry is not successful after maxRetries, the future is completed with its last result.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Backoff
  2. Serializable
  3. Product
  4. Equals
  5. RetryWithDelay
  6. Policy
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Backoff(logger: TracedLogger, flagCloseable: PerformUnlessClosing, maxRetries: Int, initialDelay: FiniteDuration, maxDelay: Duration, operationName: String, longDescription: String = "", actionable: Option[String] = None, retryLogLevel: Option[Level] = None, suspendRetries: Eval[FiniteDuration] = Eval.now(Duration.Zero))(implicit jitter: Jitter = Jitter.full(maxDelay))

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val actionable: Option[String]
  5. def apply[T](task: => Future[T], retryable: ExceptionRetryable)(implicit success: Success[T], executionContext: ExecutionContext, traceContext: TraceContext): Future[T]

    A com.digitalasset.canton.util.retry.Success criteria is supplied to determine whether the future-based task has succeeded, or if it should perhaps be retried.

    A com.digitalasset.canton.util.retry.Success criteria is supplied to determine whether the future-based task has succeeded, or if it should perhaps be retried. Retries are not performed after the com.digitalasset.canton.lifecycle.FlagCloseable has been closed. In that case, the Future is completed with the last result (even if it is an outcome that doesn't satisfy the success predicate).

    Definition Classes
    RetryWithDelayPolicy
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  8. val directExecutionContext: DirectExecutionContext
    Attributes
    protected
    Definition Classes
    Policy
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. val flagCloseable: PerformUnlessClosing
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  12. val initialDelay: FiniteDuration
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. val logger: TracedLogger
  15. val longDescription: String
  16. val maxDelay: Duration
  17. val maxRetries: Int
  18. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def nextDelay(nextCount: Int, delay: FiniteDuration): FiniteDuration
    Definition Classes
    BackoffRetryWithDelay
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. val operationName: String
  23. def productElementNames: Iterator[String]
    Definition Classes
    Product
  24. val retryLogLevel: Option[Level]
  25. val suspendRetries: Eval[FiniteDuration]
  26. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  27. def unlessShutdown[T](task: => FutureUnlessShutdown[T], retryable: ExceptionRetryable)(implicit success: Success[T], executionContext: ExecutionContext, traceContext: TraceContext): FutureUnlessShutdown[T]

    In contrast to com.digitalasset.canton.util.retry.RetryWithDelay.apply, this Policy completes the returned future with AbortedDueToShutdown if the retry is aborted due to the corresponding com.digitalasset.canton.lifecycle.FlagCloseable being closed or if the task itself reports a shutdown (and not with the last result).

    In contrast to com.digitalasset.canton.util.retry.RetryWithDelay.apply, this Policy completes the returned future with AbortedDueToShutdown if the retry is aborted due to the corresponding com.digitalasset.canton.lifecycle.FlagCloseable being closed or if the task itself reports a shutdown (and not with the last result).

    Unless your task does already naturally return a FutureUnlessShutdown[T], using com.digitalasset.canton.util.retry.RetryWithDelay.apply is likely sufficient to make it robust against shutdowns.

    Definition Classes
    RetryWithDelayPolicy
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @Deprecated
    Deprecated

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from RetryWithDelay

Inherited from Policy

Inherited from AnyRef

Inherited from Any

Ungrouped