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

Inject Ioc-managed HttpClient for MinioClient via constructor #675

Closed
PurplestViper opened this issue Aug 12, 2022 · 2 comments
Closed

Inject Ioc-managed HttpClient for MinioClient via constructor #675

PurplestViper opened this issue Aug 12, 2022 · 2 comments

Comments

@PurplestViper
Copy link
Contributor

In version 4.0.4 we had the MinioClient(HttpClient httpClient) constructor which unfortunately is now marked obsolete:

  • Having this function can easily use services.AddHttpClient<MinioClient>() to inject HttpClient.
  • The parameterless constructor creates an HttpClient instance. If another httpclient instance is subsequently passed in using the builder mode, we will have a garbage. Maybe we can simply set a switch, e.g. MinioClient(bool createHttpClient = true), to control whether to create in the constructor or not.
@ebozduman
Copy link
Collaborator

ebozduman commented Aug 23, 2022

PR #681 only addresses the 2nd bullet in the description of this issue above by cleaning up the previously created HttpClient instance, before creating a new one which happens when WithHttpClient or WithProxy method is called.

@ebozduman
Copy link
Collaborator

The team's decision is to go with builder pattern in methods, and this decision is valid for all MinIO implementations where ever it is applicable.
So, the bottom-line is we cannot revive back the methods, which went into obsolete/deprecated mode for this reason.

ebozduman pushed a commit that referenced this issue Aug 30, 2022
* Created when there is still no HttpClient available during Build().

* WithHttpClient(HttpClient) adds parameter bool disposeHttpClient = false to indicate whether to dispose httpClient.

* Fix unit tests

* run "cleanupcode minio.sln"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants