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

Introduce HttpClientFactory in HttpClient #2036

Closed
ewoutkramer opened this issue Apr 6, 2022 · 5 comments
Closed

Introduce HttpClientFactory in HttpClient #2036

ewoutkramer opened this issue Apr 6, 2022 · 5 comments

Comments

@ewoutkramer
Copy link
Member

In (closed) issue #2032 , the discussion centered around re-using instances of the HttpClient. Currently, every instance of the FhirClient creates an instance of the HttpClient, but Microsoft recommends having a single HttpClient per application - which means the FhirClient should re-use one single instance.

Describe the solution you'd like
@brianpos suggests using a class called HttpClientFactory but it is unclear to me how this solves the problem.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
See issue the discussion in #2032 for more info.

@brianpos
Copy link
Collaborator

brianpos commented Apr 6, 2022

Noting through those posts it makes the point that it's not the actual HttpClient that is the issue, its the HttpMessageHandler that is the problem, and that's the thing you need to hang onto and the Factory helps manage things better.

@brianpos
Copy link
Collaborator

I think with these changes to include the HttpClient via the constructor, then we don't need to do the HttpClientHandlerFactory stuff, and if someone wants to use that stuff, they can and we don't need to be involved.
(and we get the other unit testing benefits too as I've mentioned in the PRs.)

@vankampenp
Copy link

The HttpClientFactory creates and manages HttpClient instances and takes an available message handler from the pool. The HttpClient should be included in the constructor rather than the factory, so the consumer can reuse the same HttpClient.

@brianpos
Copy link
Collaborator

brianpos commented May 2, 2022

@ewoutkramer, Now that the 3.8.3 and 4 beta release have the httpclient in the constructor of the fhirclient, I think we can close this issue as it enables the HttpClientFactory to be used without change in this library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants