-
Notifications
You must be signed in to change notification settings - Fork 315
Adds support for automatic retry on 502, 503, and 500 errors + refactoring of duplicated code #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
So far the configuration support has not yet been implemented into WebAPI factory as I'm not sure how to do it properly (-> in a way it doesn't clash with your design ideas). |
SpotifyAPI/Web/SpotifyWebAPI.cs
Outdated
| public int RetryAfter { get; set; } = 50; | ||
|
|
||
| /// <summary> | ||
| /// Should a failed request (Error 500, 502, or 503) be automatically retried or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A reference to the RetryErrorCodes-property would be better than 500, 502 etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Hi, Thanks for the PR, good idea! I left some comments, maybe you can take a look @petrroll |
| /// <summary> | ||
| /// Error codes that will trigger auto-retry if <see cref="UseAutoRetry"/> is enabled. | ||
| /// </summary> | ||
| public IEnumerable<int> RetryErrorCodes { get; private set; } = new int[] { 500, 502, 503 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any specific reason you went for private set here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, looking at it... not really. For some reason I thought it shouldn't be a part of public API but can't remember why right now.
I might have not wanted to deal with null values, possibly.
Made a fix for it (petrroll@e5a5136), happy to PR it if you want. @JohnnyCrazy
|
Thanks again! :) |
Hi, I've had some problems with Spotify API returning 502 errors randomly on all types of requests so I thought that adding an automatic retry support into the library might be a good idea.
It's off by default and it's fully configurable. You can specify the maximum number of tries and the time between individual attempts.
It's implemented for all requests both in synchronous and async variants.