Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

nduijvelshoff
Copy link
Contributor

@nduijvelshoff nduijvelshoff commented Jun 22, 2018

@nduijvelshoff nduijvelshoff changed the title Throttle requests/sdk csharp#80 Added RetryHandler. (bunq/sdk_csharp#80) Jun 22, 2018
@nduijvelshoff
Copy link
Contributor Author

@OGKevin I don't see why my commit message is failed, the regex is a full match.
image

@OGKevin
Copy link
Contributor

OGKevin commented Jun 25, 2018

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()))
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(3, retryAttempt)))
.ExecuteAsync(() => base.SendAsync(request, cancellationToken));
}
}
Copy link
Contributor

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>()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 ?

@OGKevin
Copy link
Contributor

OGKevin commented Jun 29, 2018

@nduijvelshoff are you going to finish this ?

@nduijvelshoff
Copy link
Contributor Author

@OGKevin Hi Kevin, I can do this... Just a bit busy this week. :-)

@nduijvelshoff nduijvelshoff force-pushed the throttle-requests/sdk_csharp#80 branch from 5bda31a to 8ce7884 Compare June 29, 2018 10:05
@nduijvelshoff
Copy link
Contributor Author

nduijvelshoff commented Jun 29, 2018 via email

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