You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
publicstatic IHttpClientBuilder AddResiliencePipelineHandler(thisIHttpClientBuilderbuilder,Func<IServiceProvider,HttpRequestMessage,ResiliencePipeline<HttpResponseMessage>>policySelector){// add implementation details in a polly v8 centric way}publicstatic IHttpClientBuilder AddResiliencePipelineHandlerFromRegistry(thisIHttpClientBuilderbuilder,Func<ResiliencePipelineRegistry<string>,HttpRequestMessage,ResiliencePipeline<HttpResponseMessage>>policySelector){// add implementation details in a polly v8 centric way}//TODO: port HttpRequestMessageExtensions so that we can get & set ResilienceContext on HttpRequestMessages if that is still a relevant construct for v8
setup the registry, pipelines, & decorate the http clients...
// add the resilience pipelines - somewhere in startup or some method that has access to IServiceCollection... :// Create (and register with DI) a resilience pipeline registry containing some strategies we want to use.// standard resilience pipeline
services.AddResiliencePipeline<string,HttpResponseMessage>(StandardResiliencePipelineName,builder =>{varstandardResilienceOptions=new HttpStandardResilienceOptions(); builder.AddRateLimiter(standardResilienceOptions.RateLimiter).AddTimeout(standardResilienceOptions.TotalRequestTimeout)// 30s.AddRetry(standardResilienceOptions.Retry)// max 3.AddCircuitBreaker(standardResilienceOptions.CircuitBreaker).AddTimeout(standardResilienceOptions.AttemptTimeout);// 10s});// noop pipeline
services.AddResiliencePipeline<string,HttpResponseMessage>(NoOpPipelineName,builder =>{ builder.AddPipeline(ResiliencePipeline.Empty);});// add resilience pipeline handlers to all your http clients
services.AddHttpClient<ResilientHttpClient>().AddResiliencePipelineHandler(PipelineSelector);oralternately...
services.AddHttpClient<ResilientHttpClient>().AddResiliencePipelineHandlerFromRegistry(PipelineSelector);
create a PipelineSelector method that can be used to dynamically select the Pipeline based on the HttpVerb
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:
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: