-
Notifications
You must be signed in to change notification settings - Fork 123
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
feat: support public methods to use autogenerated admin clients. #2878
Merged
Merged
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
edc5bbf
fix: prevent illegal negative timeout values into thread sleep() meth…
arpan14 49a85df
Merge pull request #1 from arpan14/retryerror
arpan14 4cd497b
Fixing lint issues.
arpan14 4a6aa8e
Merge branch 'googleapis:main' into main
arpan14 b2aa09d
Merge branch 'googleapis:main' into main
arpan14 8d6d71e
Merge branch 'googleapis:main' into main
arpan14 77e6e7d
Merge branch 'googleapis:main' into main
arpan14 e8b7fad
Merge branch 'googleapis:main' into main
arpan14 8aa84e1
Merge branch 'googleapis:main' into main
arpan14 57fd405
Merge branch 'googleapis:main' into main
arpan14 1253563
Merge branch 'googleapis:main' into main
arpan14 d4f6a60
Merge branch 'googleapis:main' into main
arpan14 3efaf7c
Merge branch 'googleapis:main' into main
arpan14 f41b39f
Merge branch 'googleapis:main' into main
arpan14 7e3287f
Merge branch 'googleapis:main' into main
arpan14 5d090ea
feat: support emulator with autogenerated admin clients.
arpan14 5c9c2e4
chore: modifying public interfaces and adding an integration test.
arpan14 bd4156b
chore: add deprecated annotations and add docs.
arpan14 8b5d800
chore: making interface methods default.
arpan14 500fd02
chore: add clirr ignore checks for public methods.
arpan14 832077e
Merge branch 'main' into admin-emulator-support
arpan14 0be2719
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Sp…
arpan14 ab05f88
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Sp…
arpan14 bb41cf7
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Sp…
arpan14 3e8caa2
Update google-cloud-spanner/src/main/java/com/google/cloud/spanner/Sp…
arpan14 f71a4c1
chore: address PR comments.
arpan14 8330718
chore: decouple client stub objects and rely on common stub settings …
arpan14 d7f70fa
chore: remove unused map objects.
arpan14 07c9cd1
chore: fix broken unit tests.
arpan14 447ec3a
chore: handle case when client is terminated/shutdown
arpan14 3dd7017
chore: change to create methods and avoid stale instances.
arpan14 543fed9
Revert "chore: fix broken unit tests."
arpan14 53d4c7b
test: add more unit tests.
arpan14 d8d6a5b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
This method returns an instance of
com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient
. That interface implementsAutoCloseable
. That again means that most users will be inclined to put it in atry-with-resources
block, or in some other way close it when they are done. If they do that, then the underlyingstub
that is used by the client will be closed, which again is a shared object, and means that all existing and also future instances that will be returned by this method will use a closed stub.So we need to make a choice here whether:
close()
on the instance that is returned.close()
behavior. The modified behavior could either be to do nothing, or to throw an exception that indicates that this instance is managed by theSpanner
instance that created it.I think that option 3 is the safest option.
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.
Thanks for the catch!
Thinking a bit more on the issue, I think its due to the dependency on the
stub
making it a shared resource when it should not have been one. Another approach which I explored was to make use of the sharedDatabaseAdminStubSettings
andInstanceAdminStubSettings
objects and creating a newstub
objects from these settings by doing something likegapicRpc.getDatabaseAdminStubSettings().createStub()
. This will ensure we avoid the coupling and at the same time are able to re-use all the code ofGapicSpannerRpc
for creating the settings.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.
Based on offline conversations, we found an additional issue. For ex - refer the below snippet where we would still up see the shared stub behavior.
I explored two other approaches based on @olavloite 's suggestion
ManagedDatabaseAdminClient
which extends theDatabaseAdminClient
class and overrides theclose()
method. This is not possible to implement since the method is marked as final and hence we cannot override it.DatabaseAdminClient
does not implement any interface that can supply all its methods.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.
We are settling for an approach where we return a new instance each time a client object is requested. This makes sure we don't run into any edge cases (like discussed above). At the same time, we have captured in the method documentation that customers may choose to cache the instances based on their application side code.