-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RetryingReadableStore to support retrying on only certain exceptions #214
Comments
What do you think of passing in |
Good idea! I think that'd be more flexible for consumers. |
I'm not sure if I should modify It'll look like: class RetryingReadableStore[-K, +V](store: ReadableStore[K, V], backoffs: Iterable[Duration])(pred: Try[Option[V]] => Try[Option[V]])(implicit timer: Timer) extends ReadableStore[K, V] {
private[this] def getWithRetry(k: K, backoffs: Iterable[Duration]): Future[Option[V]] =
store.get(k) transform { vOpt =>
Future.const(pred(vOpt))
} transform {
case Return(t) => Future.value(t)
case Throw(e) =>
backoffs.headOption match {
case None => FutureOps.retriesExhaustedFor(k)
case Some(interval) => interval match {
case Duration.Zero => getWithRetry(k, backoffs.tail)
case Duration.Top => FutureOps.missingValueFor(k)
case _ => Future.flatten {
timer.doLater(interval) {
getWithRetry(k, backoffs.tail)
}
}
}
}
}
override def get(k: K) = getWithRetry(k, backoffs)
} Please let me know what you think |
Not sure what An alternative can perhaps be |
I would like to only retry on some exceptions. For example, these exceptions:
But I wouldn't want to retry on some other exceptions (e.g. application-level exceptions). Therefore, I need a way to specify it.
The text was updated successfully, but these errors were encountered: