Summary
Nexar creates its own HttpClient instances internally, which is not compatible with the recommended IHttpClientFactory pattern in ASP.NET Core. This leads to socket exhaustion issues in long-running applications.
Problem
- No DI (Dependency Injection) friendly constructor
- Cannot plug into named or typed HTTP clients registered via
IHttpClientFactory
- Not compatible with ASP.NET Core's built-in resilience and retry pipelines (e.g., Polly)
Proposed Solution
- Add a constructor overload that accepts an
HttpClient instance
- Provide extension methods for
IServiceCollection to register Nexar with DI
// Registration
services.AddNexar(config => {
config.BaseUrl = "https://api.example.com";
});
// Usage via DI
public class MyService(INexar nexar) { }
Summary
Nexar creates its own
HttpClientinstances internally, which is not compatible with the recommendedIHttpClientFactorypattern in ASP.NET Core. This leads to socket exhaustion issues in long-running applications.Problem
IHttpClientFactoryProposed Solution
HttpClientinstanceIServiceCollectionto register Nexar with DI