Created
February 8, 2013 19:53
-
-
Save dmichael/4741501 to your computer and use it in GitHub Desktop.
Retryer usage
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
| # 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) -> | |
Author
Depends what you are trying to do. Do you want the retrier to stop on its own - or under some condition?
Author
Check this file
https://github.com/ThomsonReutersEikon/chat/blob/retried-commands/app/assets/javascripts/shared/retryer.js.coffee#L60
That is what cancels the retry
🍕
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks like the caller of the retry is canceling the promise, don't get how the wrapped function is canceling the promise.