Skip to content

Instantly share code, notes, and snippets.

@bobthemighty
Created November 8, 2016 08:13
Show Gist options
  • Save bobthemighty/e3c7133bbd52f0bd6a1d4ff217ae7a01 to your computer and use it in GitHub Desktop.
Save bobthemighty/e3c7133bbd52f0bd6a1d4ff217ae7a01 to your computer and use it in GitHub Desktop.
def doSomethingThatMightFail():
attempts = 0
success = False
retry = True
while retry and not success:
success = call_the_service()
if attempts ++ > MAX_ATTEMPTS:
retry false
else:
jitter = random.next(0, 200) // random jitter between 0 and 200 ms.
wait_time = 100 * (attempts ** 2) // 100 ms, then 400 ms, then 900 ms, then 1600 ms....
wait_for( jitter + wait_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment