-
Notifications
You must be signed in to change notification settings - Fork 22
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
Added RetryHandler. (bunq/sdk_csharp#80) #106
base: develop
Are you sure you want to change the base?
Added RetryHandler. (bunq/sdk_csharp#80) #106
Conversation
nduijvelshoff
commented
Jun 22, 2018
•
edited
Loading
edited
- Closes Add middleware/handler to throttle requests to conform to API rate limit #80
- Tested
@OGKevin I don't see why my commit message is failed, the regex is a full match. |
Yea the regex failure seems magic to me as well. But to my eyes it loos good so we will ignore it 😉 |
@@ -99,7 +99,7 @@ public ApiClient(ApiContext apiContext) | |||
|
|||
private HttpClient CreateHttpClient() | |||
{ | |||
return new HttpClient(CreateHttpClientHandler()) | |||
return new HttpClient(new RetryHandler(CreateHttpClientHandler())) |
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.
can the retry handler be included inside the CreateHttpClientHandler
method ?
Looks better.
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.
I did this based on the example, but this can be done I think.
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.
When I move the RetryHandler is it showing some errors.
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.
Kept it on the same place due to error when changing it.
BunqSdk/Http/RetryHandler.cs
Outdated
.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(3, retryAttempt))) | ||
.ExecuteAsync(() => base.SendAsync(request, cancellationToken)); | ||
} | ||
} |
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.
Missing new line at EOF.
HttpRequestMessage request, | ||
CancellationToken cancellationToken) => | ||
Policy | ||
.Handle<HttpRequestException>() |
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.
Only do this on the bunq 429 exception please.
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.
This is now in the code.
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 i meant to only retry when this exception is thrown TooManyRequestsException
Cant you use this exception to catch and handle ?
@nduijvelshoff are you going to finish this ? |
@OGKevin Hi Kevin, I can do this... Just a bit busy this week. :-) |
5bda31a
to
8ce7884
Compare
I'll check it on Monday. Off for the weekend.
On Jun 29, 2018 16:34, Kevin Hellemun <[email protected]> wrote:
@OGKevin commented on this pull request.
________________________________
In BunqSdk/Http/RetryHandler.cs<#106 (comment)>:
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
+using Polly;
+
+namespace Bunq.Sdk.Http
+{
+ public class RetryHandler : DelegatingHandler
+ {
+ public RetryHandler(HttpClientHandler handler) : base(handler) { }
+
+ protected override Task<HttpResponseMessage> SendAsync(
+ HttpRequestMessage request,
+ CancellationToken cancellationToken) =>
+ Policy
+ .Handle<HttpRequestException>()
Hmm i meant to only retry when this exception is thrown TooManyRequestsException Cant you use this exception to catch and handle ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#106 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADmub1dzoiWAyt2hlIhFrXIanwq58DQEks5uBjrhgaJpZM4UzoCV>.
|