-
Notifications
You must be signed in to change notification settings - Fork 513
Allow creation of synchronous MinioClient using already created MinioAsyncClient #1685
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
Open
jgolda
wants to merge
1
commit into
minio:master
Choose a base branch
from
jgolda:feature/protected_minio_client_constructor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are creating a different
MinioAsyncClientand inheritMinioClient, why not have your own class inheritingMinioAsyncClient?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intend to use a class inheriting MinioAsyncClient - say CustomMinioAsyncClient. There I override the supplyAsync method, providing my own executor. It works fine.
The problem is I cannot create an instance of MinioClient nor it's subclass, which would be configured with a CustomMinioAsyncClient. The only constructor in MinioClient accepting MinioAsyncClient is private. This blocks me from crating a synchronous client (relatively easily), which will use a custom Executor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rationale behind using custom async and sync? why not use it directly?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practise I only need the sync client. I override the async client only to provide a custom Executor, which executes everything on the calling thread (Runnable::run).
With the private constructor in MinioClient I can't reuse the already existing error handling logic in MinioClient and have to copy-paste this boilerplate to my project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinioClientjust doesWhat do you mean by
error handling logic in MinioClient? I do not think this PR adds value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean exactly what you posted. It's not much, but it has to be done for every method used from async client, adding significant amount of boilerplate to projects. It's especially frustrating that this code already exists and has to be copy pasted to the project and maintained for no good reason.
It would be really cool if it could be avoided by using existing code from the MinioClient.
Changing the constructor visibility is just my first idea - I'll b fine with a static factory method (eg. MinioClient.withAsyncClient(MinioAsyncClient) or some builder option if you prefer it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you
try/catchfor every single call ofasyncclient. As themasteris a breaking change, you anyway need to fix your code irrespective of this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I do try/catch for every method I use from async client, as I need to do more or less everything the sync client does. Now I'm copying parts of it to my code, which gives me 100-150 lines of boilerplate to support and merge with future min.io versions.
As far as I recall master didn't change much in terms of error handling, so aligning code to changes in master wouldn't improve much I guess. It won't remove the boilerplate, it might make it different.
You're clearly negative about this change. Does it break anything or would you like it done differently? I'm open to some different approach which will allow me to avoid the boilerplate, but I would need some directions on what should be improved