-
Notifications
You must be signed in to change notification settings - Fork 764
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 AddResiliencePipelineHandlerFromRegistry and AddResiliencePipelineHandler to Microsoft.Extensions.Http.Resilience #4893
Comments
This is duplicate of #4666, but I vote to keep this one as it has more details :) Anyway, in #4858 we exposed services
.AddHttpClient("my-client")
.AddHttpMessageHandler(servicerProvider =>
{
return new ResilienceHandler(request => PipelineSelector(servicerProvider, request));
}); Give how simple it is, I am thinking whether it makes sense to add these APIs? FYI, the |
Hi @geeknoid @martintmk , For #4858 , do we have plan to remove the
As I am not sure if the |
/cc: @joperezr @dotnet/dotnet-extensions-resilience |
By removing the // The class name will become "stable".
public class ResilienceHandler
{
// The following two ctors will become "stable" too.
public ResilienceHandler(Func<HttpRequestMessage, ResiliencePipeline<HttpResponseMessage>> pipelineProvider);
public ResilienceHandler(ResiliencePipeline<HttpResponseMessage> pipeline);
} These APIs look solid, and I think we can make them stable. This issue is not directly related to making |
Let's get these in, these are useful additions. |
Background and motivation
In the aspnetcore extensions repo, in the Microsoft.Extensions.Http.Polly project there are extension methods for HttpClientBuilder so that you can use polly v7 constructs to append policies to an http client. The same methods have not been ported to use the polly v8 constructs in the Microsoft.Extensions.Http.Resilience package.
Are their any plans to port the following:
public static IHttpClientBuilder AddPolicyHandler( this IHttpClientBuilder builder, Func<HttpRequestMessage, IAsyncPolicy<HttpResponseMessage>> policySelector)
and
public static IHttpClientBuilder AddPolicyHandlerFromRegistry( this IHttpClientBuilder builder, Func<IReadOnlyPolicyRegistry<string>, HttpRequestMessage, IAsyncPolicy<HttpResponseMessage>> policySelector)
along with the HttpRequestMessageExtensions so that we can use native polly v8 contructs from the Microsoft.Extensions.Http.Resilience package? At this point I have to use the sundry.extensions.http.polly library to bridge this gap.
Maybe there is a way to do what I need with existing libaries and I just cannot see how to do it with polly v8 constructs.
My main motivation for being able to do this is b/c I like to define a TransientHttpFaultPipeline, a StandardResiliencePipeline, and a NoOpPipeline and add them to a ResiliencePipelineRegistry and then lookup which pipeline to use based on the Http Verb being sent into the PolicySelector / PipelineSelector. I still need to be able to do noop on http post.
API Proposal
API Usage
define pipeline names...
setup the registry, pipelines, & decorate the http clients...
create a PipelineSelector method that can be used to dynamically select the Pipeline based on the HttpVerb
Alternative Designs
cannot think of any
Risks
this might not be relevant for v8? but it seems like it is?
there might already be a way to do this and I just cannot find it, but ive spent a solid 5 business days on it digging thru polly v8, simmy, micrososft.extensions.http.polly, and micrososft.extensions.http.resilience.
The text was updated successfully, but these errors were encountered: