-
Notifications
You must be signed in to change notification settings - Fork 582
Transient Fault Handling #497
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
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.
First of all, great work!
I just have a few quick changes to start:
- Please resolve the merge conflict
- Please move this functionalities to the Helpers folder: https://github.com/sendgrid/sendgrid-csharp/tree/master/src/SendGrid/Helpers
Thank you!
Sure - who updates the nuspec file? Should that be part of the PR, or do I leave to you? If me, suggest change to 9.6.1 |
I will be updating the nuspec file. When I do a minor version bump I start at patch zero. So we would go to 9.6.0. Thanks! |
Hi @dylan-asos, This is just about ready for merge. I have one more ask, could you please add a section here that demonstrates usage? With Best Regards, Elmer |
Perfect, thank you @dylan-asos! |
Hello @dylan-asos, |
You're welcome - we'll be using this package in our project so it helps us out. Hopefully there won't be any, but any bugs or issues raised relating to this just tag me & I'll be happy to look |
NB: The nuspec file needs the Polly dependency adding. please see the example on my fork, https://github.com/dylan-asos/sendgrid-csharp/blob/master/nuspec/Sendgrid.9.5.2.nuspec |
I'll be fixing this today, @dylan-asos, thanks for making the PR so quickly! There are some concerns about the added complexity of the Polly dependency here. Fixing this issue should be a step in the right direction. |
Yep I've been following that thread - we certainly can do it without Polly and roll our own. What we need is in the options (RetryCount / Interval), so our own try\catch could achieve the same thing. Your proposal there sounds good, I'll close the outstanding PR and rework to lose the dependency. |
That's awesome @dylan-asos! Thanks for pushing forward on this :D |
This PR seems to retry all calls no matter what the error is. Was that the intent? Did you intend to only retry when SendGrid throws |
This PR implements retry behaviour for transient faults when using HttpClient to send the request.
For full backwards compatibility, default behaviour of retry logic is off. Consumer of the library must explicitly enable this using the ReliabilitySettings
Retry logic implemented as a delegating handler in the HttpClient handlers pipeline
New object ReliabilitySettings defines retry count and retry interval. Setting retry count > 0 enables the behaviour.
New object SendGridClientOptions defines the settings to use with SendGridClient, and new ctor allows this object,
public SendGridClient(SendGridClientOptions options)
NB: The overloads were getting quite large and using a options object should allow future changes with no new ctors required. I could've added the reliability settings into one of the ctors, but this way seems cleaner and more future proof.
Testing: The retry logic is tested independently of the main Integration test class in new class RetryDelegatingHandlerTests.cs - just for maintainability and execution time of the unit test, we can test this behaviour independently. Am happy to stick to convention if you'd prefer it all in one file, let me know.
This should be fully backward compatible for all existing consumers - comments welcome, let me know if any issues.