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

feat(spanner): spanner::Client construction from Options #7706

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

devbww
Copy link
Contributor

@devbww devbww commented Dec 7, 2021

Add a new spanner::Client constructor using google::cloud::Options.
This can then be used to merge with per-operation Options in a follow
up PR.

ClientOptions construction is still supported for compatibility, but
it is immediately converted to an Options value. QueryOptions
is still a first-class citizen, however, because of its use in the
Connection interface.


This change is Reviewable

Add a new `spanner::Client` constructor using `google::cloud::Options`.
This can then be used to merge with per-operation `Options` in a follow
up PR.

`ClientOptions` construction is still supported for compatibility, but
it is immediately converted to an `Options` value.  `QueryOptions`
is still a first-class citizen, however, because of its use in the
`Connection` interface.
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Dec 7, 2021
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: b57abf35427df6a5793686f00556304791e06fbe

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@codecov
Copy link

codecov bot commented Dec 7, 2021

Codecov Report

Merging #7706 (b57abf3) into main (654a652) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7706   +/-   ##
=======================================
  Coverage   95.29%   95.30%           
=======================================
  Files        1254     1256    +2     
  Lines      113620   113697   +77     
=======================================
+ Hits       108273   108354   +81     
+ Misses       5347     5343    -4     
Impacted Files Coverage Δ
google/cloud/spanner/client_options.h 100.00% <ø> (ø)
google/cloud/spanner/query_options.h 100.00% <ø> (ø)
google/cloud/spanner/client.cc 98.50% <100.00%> (+<0.01%) ⬆️
google/cloud/spanner/client.h 100.00% <100.00%> (ø)
google/cloud/spanner/client_options.cc 100.00% <100.00%> (ø)
google/cloud/spanner/client_options_test.cc 100.00% <100.00%> (ø)
google/cloud/spanner/query_options.cc 100.00% <100.00%> (ø)
google/cloud/spanner/query_options_test.cc 100.00% <100.00%> (ø)
google/cloud/pubsub/samples/samples.cc 92.02% <0.00%> (-0.08%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 654a652...b57abf3. Read the comment docs.

@devbww devbww marked this pull request as ready for review December 7, 2021 08:05
@devbww devbww requested a review from a team as a code owner December 7, 2021 08:05
Copy link
Member

@dbolduc dbolduc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left some FYIs, which you probably already know and decided to improve on.

*
* Note that the previous constructor, which uses the new way to represent
* options of all varieties (`google::cloud::Options`), is now preferred.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mark as @deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I planned to leave deprecating ClientOptions to a later stage.

* @note This constructor exists solely for backwards compatibility. It
* prevents existing code that uses `Client(conn, {})` from breaking
* due to ambiguity introduced by the `Options` overload.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pubsub, I introduced this constructor as @deprecated, to scare away any users reading the documentation. In the long run, we do want to remove the function, but, we also want Client(conn, {}) to be valid code that calls the Options constructor. (So I'm not sure using @deprecated was correct).

Changing from a @note to a @warning is also possible. I'll let you decide if you think either of these are improvements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think @deprecated is best for the reasons you cite. And indeed, @warning falls to the same logic methinks. The @note is really just an answer to "What's this?", and it all goes away when ClientOptions does.

* Convert the `ClientOptions` to the new, recommended way to represent
* options of all varieties, `google::cloud::Options`.
*/
explicit operator Options() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in pubsub a conversion method like this was hidden away in internal with the logic being that ClientOptions was to be deprecated, so no public methods should be added to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that a customer might want to call this as part of their own migration, but I'm just guessing. In any case, with ClientOptions on the road to removal I'm not too concerned about adding to the API.

@devbww devbww merged commit 5e0e6d7 into googleapis:main Dec 7, 2021
@devbww devbww deleted the spanner-options-span branch December 7, 2021 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants