in storehaus-core/src/main/scala/com/twitter/storehaus/RetryingStore.scala [61:77]
private def find[T](futures: Iterator[(Future[T], Duration)])(pred: T => Boolean): Future[T] = {
if (!futures.hasNext) {
Future.exception(new RuntimeException("RetryingRWStore: empty iterator in function find"))
} else {
val (next, delay) = futures.next()
if (!futures.hasNext) {
next
} else {
next.filter(pred).rescue {
case e: Exception =>
timer.doLater(delay)(()) flatMap { _ =>
find(futures)(pred)
}
}
}
}
}