The Retry type represents a computation that is retrying itself in case of an exception.
The Retry type represents a computation that is retrying itself in case of an exception. It uses a RetryStrategy
as a policy for the retry operation.
The result may be successful consisting of the computation result value or a failure that
is wrapping the underlying exception. The type is similar to the scala scala.util.Try type.
Example:
import scala.concurrent.duration._
import util.retry.blocking.{RetryStrategy, Failure, Retry, Success}
implicitval retryStrategy =
RetryStrategy.fixedBackOff(retryDuration = 1.seconds, maxAttempts = 2)
val r = Retry(1 / 1) match {
case Success(x) => x
case Failure(t) => log("Exception occurred", t)
}
The
Retry
type represents a computation that is retrying itself in case of an exception. It uses aRetryStrategy
as a policy for the retry operation.The result may be successful consisting of the computation result value or a failure that is wrapping the underlying exception. The type is similar to the scala scala.util.Try type.
Example: