[FEATURE] Refactor to use HttpClientFactory
for HTTP client management
#231
Labels
enhancement
New feature or request
good first issue
Good for newcomers
hacktoberfest
Participation in the Hacktoberfest event
help wanted
Extra attention is needed
🕔 high effort
A task that can be completed in a few days
👷🏼 infrastructure
Infrastructure-related tasks or issues
🧑💻 tech-debit
Technical debt that needs to be addressed
🧪 tests
Tasks related to testing
Description
We need to refactor the HTTP client integration library to use
HttpClientFactory
instead of directly instantiatingHttpClient
. UsingHttpClientFactory
will help manage the lifecycle ofHttpClient
instances more effectively, improve performance, and avoid potential issues related to DNS changes and socket exhaustion.Problem Statement
HttpClient
directly within the classes, leading to potential problems such as socket exhaustion and inefficient resource management. This approach does not take advantage of the benefits provided byHttpClientFactory
.HttpClientFactory
will enhance the library's performance and reliability by managingHttpClient
instances in a more scalable and efficient manner.Proposed Solution
HttpClientFactory
for creatingHttpClient
instances instead of direct instantiation.IHttpClientFactory
where needed and use it to obtainHttpClient
instances.Implementation Steps
Update Dependencies:
HttpClientFactory
. If using ASP.NET Core, this is included by default.Refactor HTTP Client Usage:
HttpClient
is directly instantiated.HttpClientFactory
by injectingIHttpClientFactory
and using it to createHttpClient
instances.Configure
HttpClientFactory
:Startup.cs
or wherever dependency injection is configured.Test Refactoring:
HttpClient
instantiation.HttpClient
is managed properly by the factory.Documentation:
HttpClient
instances are created and managed.HttpClientFactory
with the library.Additional Notes
HttpClient
management.!The text was updated successfully, but these errors were encountered: