Skip to content

Instantly share code, notes, and snippets.

@JohnMurray
Created January 14, 2018 10:21
Show Gist options
  • Save JohnMurray/8ed3972cf04f2ff45e3328bb831e8918 to your computer and use it in GitHub Desktop.
Save JohnMurray/8ed3972cf04f2ff45e3328bb831e8918 to your computer and use it in GitHub Desktop.
Simple retries with future-based networking code in Scala (without back-off)
def networkRequestWithRetries(): Future[String] = {
networkRequest().recoverWith {
case NetworkException =>
println("retrying")
networkRequestWithRetries()
case t: Throwable => throw t
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment