-
Notifications
You must be signed in to change notification settings - Fork 1.7k
#2078 V7 polly syntax not longer supported #2079
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507"> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Polly" Version="8.3.1" /> | ||
<PackageReference Include="Polly" Version="8.4.0" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right! Good to bump the version! |
||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
using Ocelot.Errors.QoS; | ||
using Ocelot.Logging; | ||
using Ocelot.Provider.Polly.Interfaces; | ||
using Ocelot.Provider.Polly.v7; | ||
using Ocelot.Requester; | ||
using Polly.CircuitBreaker; | ||
using Polly.Registry; | ||
|
@@ -32,7 +31,7 @@ public static class OcelotBuilderExtensions | |
/// <summary> | ||
/// Adds Polly QoS provider to Ocelot by custom delegate and with custom error mapping. | ||
/// </summary> | ||
/// <typeparam name="TProvider">QoS provider to use (by default use <see cref="PollyQoSProvider"/>).</typeparam> | ||
/// <typeparam name="TProvider">QoS provider to use (by default use <see cref="PollyQoSResiliencePipelineProvider"/>).</typeparam> | ||
/// <param name="builder">Ocelot builder to extend.</param> | ||
/// <param name="delegatingHandler">Your customized delegating handler (to manage QoS behavior by yourself).</param> | ||
/// <param name="errorMapping">Your customized error mapping.</param> | ||
|
@@ -94,7 +93,7 @@ public static IOcelotBuilder AddPolly<TProvider>(this IOcelotBuilder builder) | |
/// Defaults: | ||
/// <list type="bullet"> | ||
/// <item><see cref="PollyQoSResiliencePipelineProvider"/></item> | ||
/// <item><see cref="GetDelegatingHandlerV7"/></item> | ||
/// <item><see cref="GetDelegatingHandler"/></item> | ||
/// <item><see cref="DefaultErrorMapping"/></item> | ||
/// </list> | ||
/// </remarks> | ||
|
@@ -112,96 +111,4 @@ public static IOcelotBuilder AddPolly(this IOcelotBuilder builder) | |
/// <returns>A <see cref="DelegatingHandler"/> object, but concrete type is the <see cref="PollyResiliencePipelineDelegatingHandler"/> class.</returns> | ||
private static DelegatingHandler GetDelegatingHandler(DownstreamRoute route, IHttpContextAccessor contextAccessor, IOcelotLoggerFactory loggerFactory) | ||
=> new PollyResiliencePipelineDelegatingHandler(route, contextAccessor, loggerFactory); | ||
|
||
#region Obsolete extensions will be removed in future version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love when regions are removed 😃 |
||
|
||
/// <summary> | ||
/// Adds Polly QoS provider to Ocelot by custom delegate and with custom error mapping. | ||
/// </summary> | ||
/// <typeparam name="TProvider">QoS provider to use (by default use <see cref="PollyQoSProvider"/>).</typeparam> | ||
/// <param name="builder">Ocelot builder to extend.</param> | ||
/// <param name="delegatingHandler">Your customized delegating handler (to manage QoS behavior by yourself).</param> | ||
/// <param name="errorMapping">Your customized error mapping.</param> | ||
/// <returns>The reference to the same extended <see cref="IOcelotBuilder"/> object.</returns> | ||
[Obsolete("Use AddPolly instead, it will be remove in future version")] | ||
public static IOcelotBuilder AddPollyV7<TProvider>(this IOcelotBuilder builder, QosDelegatingHandlerDelegate delegatingHandler, IDictionary<Type, Func<Exception, Error>> errorMapping) | ||
where TProvider : class, IPollyQoSProvider<HttpResponseMessage> | ||
{ | ||
builder.Services | ||
.AddSingleton(errorMapping) | ||
.AddSingleton<IPollyQoSProvider<HttpResponseMessage>, TProvider>() | ||
.AddSingleton(delegatingHandler); | ||
return builder; | ||
} | ||
|
||
/// <summary> | ||
/// Adds Polly QoS provider to Ocelot with custom error mapping, but default <see cref="DelegatingHandler"/> is used. | ||
/// </summary> | ||
/// <typeparam name="TProvider">QoS provider to use (by default use <see cref="PollyQoSProvider"/>).</typeparam> | ||
/// <param name="builder">Ocelot builder to extend.</param> | ||
/// <param name="errorMapping">Your customized error mapping.</param> | ||
/// <returns>The reference to the same extended <see cref="IOcelotBuilder"/> object.</returns> | ||
[Obsolete("Use AddPolly instead, it will be remove in future version")] | ||
public static IOcelotBuilder AddPollyV7<TProvider>(this IOcelotBuilder builder, IDictionary<Type, Func<Exception, Error>> errorMapping) | ||
where TProvider : class, IPollyQoSProvider<HttpResponseMessage> | ||
=> AddPollyV7<TProvider>(builder, GetDelegatingHandlerV7, errorMapping); | ||
|
||
/// <summary> | ||
/// Adds Polly QoS provider to Ocelot with custom <see cref="DelegatingHandler"/> delegate, but default error mapping is used. | ||
/// </summary> | ||
/// <typeparam name="TProvider">QoS provider to use (by default use <see cref="PollyQoSProvider"/>).</typeparam> | ||
/// <param name="builder">Ocelot builder to extend.</param> | ||
/// <param name="delegatingHandler">Your customized delegating handler (to manage QoS behavior by yourself).</param> | ||
/// <returns>The reference to the same extended <see cref="IOcelotBuilder"/> object.</returns> | ||
[Obsolete("Use AddPolly instead, it will be remove in future version")] | ||
public static IOcelotBuilder AddPollyV7<TProvider>(this IOcelotBuilder builder, QosDelegatingHandlerDelegate delegatingHandler) | ||
where TProvider : class, IPollyQoSProvider<HttpResponseMessage> | ||
=> AddPollyV7<TProvider>(builder, delegatingHandler, DefaultErrorMapping); | ||
|
||
/// <summary> | ||
/// Adds Polly QoS provider to Ocelot by defaults. | ||
/// </summary> | ||
/// <remarks> | ||
/// Defaults: | ||
/// <list type="bullet"> | ||
/// <item><see cref="GetDelegatingHandlerV7"/></item> | ||
/// <item><see cref="DefaultErrorMapping"/></item> | ||
/// </list> | ||
/// </remarks> | ||
/// <typeparam name="TProvider">QoS provider to use (by default use <see cref="PollyQoSProvider"/>).</typeparam> | ||
/// <param name="builder">Ocelot builder to extend.</param> | ||
/// <returns>The reference to the same extended <see cref="IOcelotBuilder"/> object.</returns> | ||
[Obsolete("Use AddPolly instead, it will be remove in future version")] | ||
public static IOcelotBuilder AddPollyV7<TProvider>(this IOcelotBuilder builder) | ||
where TProvider : class, IPollyQoSProvider<HttpResponseMessage> | ||
=> AddPollyV7<TProvider>(builder, GetDelegatingHandlerV7, DefaultErrorMapping); | ||
|
||
/// <summary> | ||
/// Adds Polly QoS provider to Ocelot by defaults with default QoS provider. | ||
/// </summary> | ||
/// <remarks> | ||
/// Defaults: | ||
/// <list type="bullet"> | ||
/// <item><see cref="PollyQoSProvider"/></item> | ||
/// <item><see cref="GetDelegatingHandlerV7"/></item> | ||
/// <item><see cref="DefaultErrorMapping"/></item> | ||
/// </list> | ||
/// </remarks> | ||
/// <param name="builder">Ocelot builder to extend.</param> | ||
/// <returns>The reference to the same extended <see cref="IOcelotBuilder"/> object.</returns> | ||
[Obsolete("Use AddPolly instead, it will be remove in future version")] | ||
public static IOcelotBuilder AddPollyV7(this IOcelotBuilder builder) | ||
=> AddPollyV7<PollyQoSProvider>(builder, GetDelegatingHandlerV7, DefaultErrorMapping); | ||
|
||
/// <summary>< 9E88 /td> | ||
/// Creates default delegating handler based on the <see cref="PollyPoliciesDelegatingHandler"/> type. | ||
/// </summary> | ||
/// <param name="route">The downstream route to apply the handler for.</param> | ||
/// <param name="contextAccessor">The context accessor of the route.</param> | ||
/// <param name="loggerFactory">The factory of logger.</param> | ||
/// <returns>A <see cref="DelegatingHandler"/> object, but concrete type is the <see cref="PollyPoliciesDelegatingHandler"/> class.</returns> | ||
private static DelegatingHandler GetDelegatingHandlerV7(DownstreamRoute route, IHttpContextAccessor contextAccessor, IOcelotLoggerFactory loggerFactory) | ||
=> new PollyPoliciesDelegatingHandler(route, contextAccessor, loggerFactory); | ||
|
||
#endregion | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
// Default Microsoft.NET.Sdk namespaces | ||
// Project extra global namespaces | ||
global using Polly; | ||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.Linq; | ||
global using System.Net.Http; | ||
global using System.Threading; | ||
global using System.Threading.Tasks; | ||
|
||
// Project extra global namespaces | ||
global using Polly; |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these lines can be retained and relocated to an earlier position.