-
Notifications
You must be signed in to change notification settings - Fork 2
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
Switch to using async all the way #111
Conversation
Thanks, that's quite a PR 😆 Could you explain to us non-experts what the advantage is of switching to async calls? And whether it makes sense to support both sync and async calls? |
Thank you for the quick response @mroloux . I'll try my best to explain it in simple terms and also put in some recommended links/articles 😀 Async/Await is the way to perform asynchronous programming in .NET. When synchronously calling the HTTP methods you are essentially blocking the calling thread until you get back a response from the other side. Whereas with using asynchronous programming, as soon as you submit your HTTP request, the calling thread is free to do other work, until you get back a response from the other side. This is a great reference on introduction to Asynchronous Programming in .NET Support both sync and async? I don't think there is a need to do this. Given that you are already using public static RestResponse Execute(this IRestClient client, RestRequest request, Method httpMethod)
=> AsyncHelpers.RunSync(() => client.ExecuteAsync(request, httpMethod)); You can also read more about it here. Do you see a need to support sync versions as well? If required by any of the consumers, they can use the same Let me know if that help. |
Alright. Let's go with the async version then. I would use the original method names though, e.g. Also, should we add an optional |
@mroloux Great! Adding in a cancellation token sounds excellent. I will update the PR. As for keeping the same Function name, this might cause issues for anyone using it today unless they make sure to add the await keyword. Having the function name different will force them to look at all the places explicitly and change to the But this could be something that can be called out in the release doc/Readme. Happy to go with whatever way you decide to go ahead with! |
Yeah, it's a tradeoff. But I'm afraid we'll never get rid of the The release notes will need to be very clear about this of course. |
@mroloux Having the Async suffix is a general convention in .NET. Here is a guideline from Microsoft.
It is even more helpful in this case since it's a breaking change. That said, I will leave it to you to finalize before I work on the PR again next week. Have a good weekend 😀 |
Ok, let's keep the |
One small remark: it would be nice if This assertion should work:
|
- Ensure to create the charts one after the other to test that the charts returned are in expected order.
@mroloux Added in cancellation token support and also ensured that |
This will force to update the code and make sure to add await in the consumer code
Should it be?
#55