-
Notifications
You must be signed in to change notification settings - Fork 762
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
Cleanup Microsoft.Extensions.Http.Resilience internals #4141
Conversation
using System.Net.Http; | ||
|
||
namespace Microsoft.Extensions.Http.Resilience.Internal; | ||
|
||
/// <summary> | ||
/// The provider that returns the strategy key from the request message. | ||
/// </summary> | ||
internal interface IStrategyKeyProvider | ||
internal sealed class StrategyKeyOptions |
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.
Is this type used in DI? If not, you could just be using Func<HttpRequestMessage, string> directly
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.
Yes, it comes from DI. This options class is just a holder for that delegate.
@@ -17,25 +18,22 @@ public static void SelectStrategyByAuthority(IServiceCollection services, string | |||
{ | |||
var redactor = serviceProvider.GetRequiredService<IRedactorProvider>().GetRedactor(classification); | |||
|
|||
return new ByAuthorityStrategyKeyProvider(redactor); | |||
return new ByAuthorityStrategyKeyProvider(redactor).GetStrategyKey; |
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.
Perhaps rename GetStrategyKey to just StrategyKey?
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.
GetStrategyKey
is just a function that gets converted to a delegate. I think the name is ok here
@@ -115,4 +123,12 @@ private static IServiceCollection AddHedging(this IServiceCollection services, H | |||
|
|||
return services; | |||
} | |||
|
|||
private class EmptyHandler : DelegatingHandler |
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.
[nit] Please keep one type per file. This makes it much easier to navigate the codebase - e.g., search for type in GitHub. Move to HttpClientFactory.EmptyHandler.cs.
internal const string StandardClient = "Standard"; | ||
|
||
internal const string SingleHandlerClient = "SingleHandler"; | ||
|
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.
[nit]
internal const string StandardClient = "Standard"; | |
internal const string SingleHandlerClient = "SingleHandler"; | |
internal const string StandardClient = "Standard"; | |
internal const string SingleHandlerClient = "SingleHandler"; |
Simplifying and dropping some unnecessary internal abstractions.
Changes:
RequestMessageSnapshot
.Microsoft Reviewers: Open in CodeFlow