refactor: 移除自定义 HttpClientFactory,改用依赖注入的 IHttpClientFactory

This commit is contained in:
ccnetcore
2025-09-04 22:26:06 +08:00
parent 6e2dd39246
commit ece89ebad0
7 changed files with 22 additions and 14 deletions

View File

@@ -39,6 +39,12 @@ public static class HttpClientFactory
private static readonly ConcurrentDictionary<string, Lazy<List<HttpClient>>> HttpClientPool = new();
/// <summary>
/// 高并发下有问题
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
[Obsolete]
public static HttpClient GetHttpClient(string key)
{
return HttpClientPool.GetOrAdd(key, k => new Lazy<List<HttpClient>>(() =>
@@ -70,4 +76,4 @@ public static class HttpClientFactory
return clients;
})).Value[new Random().Next(0, PoolSize)];
}
}
}