-
Notifications
You must be signed in to change notification settings - Fork 731
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
[API Proposal]: Add IHttpClientBuilder to builder interfaces returned by AddStandardResilienceHandler(), AddStandardHedgingHandler() #5165
Comments
cc @iliar-turdushev can you please take a look? Proposal seems straight forward, so if there aren't any concerns implementation-wise, we can mark it as ready-for-review. My 2 cents here of course the ideal would have been for both of those |
cc: @martintmk |
@joperezr, @martintmk what should be the next step? If you agree, I'd like to give it a try and open a pull request with the change |
For the context, when we were initially designing the API, both In the API review, nesting builders was considered as anti-pattern and we removed the reference. I see the benefits though, so if everyone agrees we can introduce this change. cc @geeknoid Your thoughts on this Proposal? |
@geeknoid ping, please |
Extending a public interface type would be a breaking change, right? |
Technically, yes. But I think it's extremely unlikely anyone uses a non-default implementation of any builder interface. Such interfaces interfaces aren't a public contact but a standard way to implement the fluent/builder API. |
@joperezr If you're OK with the potential breaking change, then I'm also OK with the change. |
I of course would rather not do a breaking change unless we absolutely have to, but as called out I also think this is very unlikely to break people. That said, I'm not really a SME on builder APIs, so I'll mark this as ready for review and check what experts like @halter73 think to make sure they agree this breaking change is okay. |
Actually, wait a sec, would this break if some code compiled against the older version of the interface (via an old package) but then ends up using a newer package with the new interface and doesn't re-compile? (mainly asking as that would change my assessment of "unlikely to break people") |
Should we get advice from ARB folks? |
How about exposing services.AddHttpClient(...)
.AddStandardResilienceHandler(...)
.HttpClientBuilder()
.AddStandardHedgingHandler(...); |
.HttpClientBuilder() Wouldn't this be awkward and inconsistent comparing to the rest of the API? e.g. the property |
This isn't something we've been super consistent with. MVC, Blazor and SignalR use interfaces for their builders. An upside of interfaces is that you can have a builder that implements multiple builders or otherwise augments the builder like
This would break implementers of the interface unless there is a DIM and the implementing type is loaded by a runtime that supports DIMs. It shouldn't break code simply calling interface methods unless those methods were removed. That said, I don't think it's worth accepting any level of breaking change just to save people from storing the |
So this is not a breaking change, correct?
The existing API is less fluent, less convenient, more chatty. Hence the proposal. |
What if we add public interface IHttpStandardResiliencePipelineBuilder
{
#if NET6_0_OR_GREATER
IHttpClientBuilder HttpClientBuilder { get => null; }
#endif
} Then |
@iliar-turdushev That sounds quite reasonable. |
Mm.... This makes me concerned. Would this pass package validation? |
@RussKie It seems that the validation passes. Please, take a look at the following PR #5215. All checks have passed. Does it mean that we are good? The UPDATE Making the property |
@iliar-turdushev ping on this, please. who should we follow up with to respond to your latest update? |
Langversion is not tied to a TFM, but instead to the tooling which can vary. I'm not a fan of forking the API surface between TFMs to be honest unless we absolutely have to which doesn't seem to be the case here. Package Validation won't fail with the proposal because the two TFMs aren't compatible with each other (meaning you can't compile against net6.0 but then execute against net462) |
@abatishchev I really appreciate the suggestion here, and I also believe that if we were to redo this we would have probably have these properties to begin with, but given we have already shipped and the potential breaking changes called above, I'm leaning to following @halter73's advice here (who is the SME on aspnetcore APIs) and not take the breaking change given the workaround is really straight forward (just store the httpclientbuilder in a variable). @iliar-turdushev or @abatishchev is there any scenario where doing the workaround wouldn't be possible? Mainly asking as that could influence whether or not we think we can take this. |
Background and motivation
Currently the top-level API methods for
Microsoft.Extensions.Http.Resilience
are:Both return an inner builder:
Each has a reference to
IServiceCollection
, but not toIHttpClientBuilder
.API Proposal
Update the builder interfaces with a reference to the original
IHttpClientBuilder
:API Usage
Currently, the user has to store a reference to
IHttpClientBuilder
manually:Instead, this would be possible:
Alternative Designs
No response
Risks
Minimal since both
HttpStandardResiliencePipelineBuilder
andStandardHedgingHandlerBuilder
are currently private classes (records).The text was updated successfully, but these errors were encountered: