我有HttpClientWrapper
,名为CarInformationClient
public class CarInformationClient
{
private readonly HttpClient _httpClient;
public CarInformationClient(HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<CarInfoResponse> GetCarInfoAsync(string customerReference)
{
var request = new CarInfoRequest
{
CustomerReference = customerReference
};
var response = await _//send data with httpclient
//do something with the response
}
}
我正在将它注册为Windsor的单身人士
Component.For<HttpClient>().LifestyleSingleton()
由于HttpClient
应该在对同一主机的调用中重复使用,如果大量客户端同时调用GetCarInfoAsync
,因为只有一个实例,这个单例实现会减慢速度HttpClient
的?我见过this question,但它并没有完全回答我的问题。