package retry
- Alphabetic
- By Inheritance
- retry
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- 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.
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. - final case class DbRetries(maxRetries: Int = Forever, suspendRetriesOnInactive: Boolean = true) extends Product with Serializable
Retries parameter for DB-backed operations.
Retries parameter for DB-backed operations.
- maxRetries
The maximum number of query retries.
- suspendRetriesOnInactive
If set, retries are suspended when the database com.digitalasset.canton.resource.Storage is inactive (see com.digitalasset.canton.resource.DbStorage.run). Set to
false
if you want to ensure thatmaxRetries
is respected regardless of the storage state.
- final case class Directly(logger: TracedLogger, performUnlessClosing: PerformUnlessClosing, maxRetries: Int, operationName: String, longDescription: String = "", retryLogLevel: Option[Level] = None, suspendRetries: Eval[FiniteDuration] = Eval.now(Duration.Zero)) extends RetryWithDelay with Product with Serializable
Retry immediately after failure for a max number of times
- sealed trait ErrorKind extends AnyRef
- trait ExceptionRetryPolicy extends AnyRef
When using retry code in different contexts, different exceptions should be retried on.
When using retry code in different contexts, different exceptions should be retried on. This trait provides a way to define what exceptions should be retried and which are fatal.
- trait Jitter extends AnyRef
- final case class Pause(logger: TracedLogger, performUnlessClosing: PerformUnlessClosing, maxRetries: Int, delay: FiniteDuration, operationName: String, longDescription: String = "", actionable: Option[String] = None, retryLogLevel: Option[Level] = None, suspendRetries: Eval[FiniteDuration] = Eval.now(Duration.Zero)) extends RetryWithDelay with Product with Serializable
Retry with a pause between attempts for a max number of times
- abstract class Policy extends AnyRef
A retry com.digitalasset.canton.util.retry.Policy defines an interface for retrying a future-based task with retry semantics specific to implementations.
A retry com.digitalasset.canton.util.retry.Policy defines an interface for retrying a future-based task with retry semantics specific to implementations. If the task throws a non-fatal exceptions synchronously, the exception is converted into an asynchronous one, i.e., it is returned as a failed future or retried.
If unsure about what retry policy to pick, com.digitalasset.canton.util.retry.Backoff is a good default.
- abstract class RetryWithDelay extends Policy
- class Success[-T] extends AnyRef
- Annotations
- @implicitNotFound()
- final case class When(logger: TracedLogger, depends: PartialFunction[Any, Policy]) extends Policy with Product with Serializable
A retry policy in which the failure determines the way a future should be retried.
A retry policy in which the failure determines the way a future should be retried. The partial function
depends
provided may define the domain of both the success OR exceptional failure of a future fails explicitly.val policy = retry.When { case RetryAfter(retryAt) => retry.Pause(delay = retryAt) } val future = policy(issueRequest)
If the result is not defined for the depends block, the future will not be retried.
Value Members
- val Forever: Int
- case object AllExceptionRetryPolicy extends ExceptionRetryPolicy with Product with Serializable
Retry on any exception.
Retry on any exception.
This is a sensible default choice for non-db tasks with a finite maximum number of retries.
- object ErrorKind
- object Jitter
The algorithms here were inspired by this article: https://www.awsarchitectureblog.com/2015/03/backoff.html
- case object NoExceptionRetryPolicy extends ExceptionRetryPolicy with Product with Serializable
Don't retry on any exception.
- object Policy
- object RetryEither
Simple form of the retry policies that operate on Either and not Future[T].
Simple form of the retry policies that operate on Either and not Future[T]. Only provides a Pause-based retry.
- object RetryWithDelay
- object Success