Created
January 14, 2018 10:21
-
-
Save JohnMurray/8ed3972cf04f2ff45e3328bb831e8918 to your computer and use it in GitHub Desktop.
Simple retries with future-based networking code in Scala (without back-off)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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