Skip to content

Instantly share code, notes, and snippets.

@dmichael
Created February 8, 2013 19:53
Show Gist options
  • Select an option

  • Save dmichael/4741501 to your computer and use it in GitHub Desktop.

Select an option

Save dmichael/4741501 to your computer and use it in GitHub Desktop.
Retryer usage
# Create the wrapped function with 5 retries
command = @commands.retry('connectToProvider', attempts: 5)
# Create the wrapped function with unlimited retries
command = @commands.retry('connectToProvider')
# Essentially a promise is returned with another method attached
promise = command('yahoo', username: 'x', password: 'y')
# Some bad shit happens
promise.cancel()
# no more retries
# Progress is reported when a request (or deferred action) fails and is retried
# - the error object is from the action's fail callback
promise.progress (object) ->
# error:
# attempts:
# interval:
# message:
# Called when the retries completely fail or the action is canceled (promise.cancel())
promise.fail (object) ->
# error:
# attempts:
# interval:
# message:
# The action succeeded
promise.done (response) ->
@mattkanwisher
Copy link
Copy Markdown

This looks like the caller of the retry is canceling the promise, don't get how the wrapped function is canceling the promise.

@dmichael
Copy link
Copy Markdown
Author

dmichael commented Feb 8, 2013

Depends what you are trying to do. Do you want the retrier to stop on its own - or under some condition?

@dmichael
Copy link
Copy Markdown
Author

dmichael commented Feb 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment