Skip to content

Conversation

@petrroll
Copy link
Contributor

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.

@petrroll
Copy link
Contributor Author

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).

public int RetryAfter { get; set; } = 50;

/// <summary>
/// Should a failed request (Error 500, 502, or 503) be automatically retried or not.
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@JohnnyCrazy
Copy link
Owner

JohnnyCrazy commented Aug 22, 2016

Hi,

Thanks for the PR, good idea!
I'm personaly not a fan of Auto-Retry, especially for 5XX error codes, since these shouldn't happen and spotify should take care of it. (Did you tell them btw.?) But I guess nothing is wrong with implementing it when it's disabled by default.

I left some comments, maybe you can take a look @petrroll

@JohnnyCrazy JohnnyCrazy merged commit eb469bd into JohnnyCrazy:master Aug 24, 2016
/// <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 };
Copy link
Owner

@JohnnyCrazy JohnnyCrazy Aug 24, 2016

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?

Copy link
Contributor Author

@petrroll petrroll Aug 24, 2016

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

@JohnnyCrazy
Copy link
Owner

Thanks again! :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants