Skip to content
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

[POC] HttpClientFactory Scope Mismatch Fix #43660

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static partial class HttpClientBuilderExtensions
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder RedactLoggedHeaders(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Collections.Generic.IEnumerable<string> redactedLoggedHeaderNames) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder RedactLoggedHeaders(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.Func<string, bool> shouldRedactHeaderValue) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder SetHandlerLifetime(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, System.TimeSpan handlerLifetime) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHttpClientBuilder SetPreserveExistingScope(this Microsoft.Extensions.DependencyInjection.IHttpClientBuilder builder, bool preserveExistingScope) { throw null; }
}
public static partial class HttpClientFactoryServiceCollectionExtensions
{
Expand Down Expand Up @@ -61,6 +62,7 @@ public HttpClientFactoryOptions() { }
public System.Collections.Generic.IList<System.Action<Microsoft.Extensions.Http.HttpMessageHandlerBuilder>> HttpMessageHandlerBuilderActions { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
public System.Func<string, bool> ShouldRedactHeaderValue { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public bool SuppressHandlerScope { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public bool PreserveExistingScope { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
}
public abstract partial class HttpMessageHandlerBuilder
{
Expand Down Expand Up @@ -112,8 +114,16 @@ public partial interface IHttpClientFactory
{
System.Net.Http.HttpClient CreateClient(string name);
}
public partial interface IScopedHttpClientFactory
{
System.Net.Http.HttpClient CreateClient(string name);
}
public partial interface IHttpMessageHandlerFactory
{
System.Net.Http.HttpMessageHandler CreateHandler(string name);
}
public partial interface IScopedHttpMessageHandlerFactory
{
System.Net.Http.HttpMessageHandler CreateHandler(string name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ internal class ActiveHandlerTrackingEntry
public ActiveHandlerTrackingEntry(
string name,
LifetimeTrackingHttpMessageHandler handler,
bool isPrimary,
IServiceScope scope,
TimeSpan lifetime)
{
Name = name;
Handler = handler;
Scope = scope;
Lifetime = lifetime;
IsPrimary = isPrimary;

_lock = new object();
}
Expand All @@ -41,6 +43,8 @@ public ActiveHandlerTrackingEntry(

public IServiceScope Scope { get; }

public bool IsPrimary { get; }

public void StartExpiryTimer(TimerCallback callback)
{
if (Lifetime == Timeout.InfiniteTimeSpan)
Expand Down
Loading