-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 Option to add Interceptors on Client Level #2118
Conversation
Removed Console.Test which is not inside Repository
…ch to propagate Exceptions to Callers
Previous Pullrequest #2108 |
Had to sync with origin, to make this running, hope it's allright, now |
My Build are currently failing, because I cannot load Microsoft.CodeAnalysis.CSharp from my nugetSources, therefore I am currently not able to run the tests. Hope this problem only exists on my PC. |
There's no "special source" as the package is on NuGet.org, which you can check for yourself. I merged the PR, but I have some follow up work to do. In particular, the interceptors list remains mutable when it's used by the client, and Another thing is that interceptors are called regardless if the collection is empty or not. Because the interceptor call is awaited, and called unconditionally, there's a performance cost involved even for people who don't use interceptors. I am trying to fix it now. |
Btw it would be nice to know if making the interceptors collection mutable was your intention, as I see it was used in tests. I am making it immutable now, but we can discuss it if you have a different use case. |
When I started the Interceptors, I don't even had Immutable Lists, or Thread Safety in mind, so I just took the default List. |
What exactly, do you mean with the Interceptors are called regardless of it they empty or not? If you mean the Interceptor Functions such, you defined ValueTasks, according to Brandon Minnick (https://github.com/brminnick/AsyncAwaitBestPractices) this should be better in performance than using Task self. |
What I mean is that every async/await call is still creating a state machine, and your Basically, the only work left is to align on handling exceptions. My proposal here is that:
I believe it allows to cover your case (set the Alternatively, it is possible to add one more |
Sounds like a good way |
@alexeyzimarev , public async Task ThrowExceptionIn_InterceptBeforeRequest_ShouldBeCatchableInTest() { EDIT: I think this was due to my question I asked in the follow redirect PR. If after request is called inside the redirection loop then the generated exception gets swallowed by exception -> response translation and throw error on failed request option is off for these tests. |
Description
Added Possibility to add Client wide Interceptors, to check Request and Responses on multiple positions
Purpose
This pull request is a:
Checklist