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(generator): merge connection options into client options #8158

Merged
merged 6 commits into from
Jan 29, 2022

Conversation

devbww
Copy link
Contributor

@devbww devbww commented Jan 29, 2022

Store the Connection options so that they may be made available to
merge into the Client options, and then use them to implement the
four polling-policy data elements. (This is the generator version
of #8090.)

Rules of thumb for Options values:

  • MergeOptions() LHS should not include the service defaults
  • MergeOptions() RHS should include service defaults
  • An OptionsSpan should include the service defaults
  • stored Options (data members) should include the service defaults

Code can then normally just look at the CurrentOptions(), knowing
that they will include the service defaults. For example, the policy
options will be available. A special exception to this, however, is
when testing the connection layer in isolation (without a client), as
no one has created an OptionsSpan in that case. We could add an
OptionsSpan to the connection-layer calls, but it would be a no-op
in practice. So, tests need to ensure required options are available.

Fixes #8054.


This change is Reviewable

Store the Connection options so that they may be made available to
merge into the Client options, and then use them to implement the
four polling-policy data elements.  (This is the generator version
of googleapis#8090.)

Rules of thumb for `Options` values:
- `MergeOptions()` LHS should not include the service defaults
- `MergeOptions()` RHS should include service defaults
- An `OptionsSpan` should include the service defaults
- stored `Options` (data members) should include the service defaults

Code can then normally just look at the `CurrentOptions()`, knowing
that they will include the service defaults.  For example, the policy
options will be available.  A special exception to this, however, is
when testing the connection layer in isolation (without a client), as
no one has created an `OptionsSpan` in that case.  We could add an
`OptionsSpan` to the connection-layer calls, but it would be a no-op
in practice.  So, tests need to ensure required options are available.

Fixes googleapis#8054.
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: ed04266e78cdff1d83ae2b36e478222e903c406e

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

@codecov
Copy link

codecov bot commented Jan 29, 2022

Codecov Report

Merging #8158 (0c68fb1) into main (223a6e0) will increase coverage by 0.00%.
The diff coverage is 97.14%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8158   +/-   ##
=======================================
  Coverage   94.58%   94.58%           
=======================================
  Files        1320     1322    +2     
  Lines      117829   117838    +9     
=======================================
+ Hits       111451   111461   +10     
+ Misses       6378     6377    -1     
Impacted Files Coverage Δ
generator/internal/client_generator.cc 29.25% <ø> (ø)
...den/internal/golden_kitchen_sink_connection_impl.h 77.77% <80.00%> (-3.48%) ⬇️
...gration_tests/golden/golden_kitchen_sink_client.cc 87.67% <100.00%> (ø)
...ion_tests/golden/golden_kitchen_sink_connection.cc 40.00% <100.00%> (+1.53%) ⬆️
...tion_tests/golden/golden_kitchen_sink_connection.h 100.00% <100.00%> (ø)
...egration_tests/golden/golden_thing_admin_client.cc 98.00% <100.00%> (ø)
...tion_tests/golden/golden_thing_admin_connection.cc 21.05% <100.00%> (+1.05%) ⬆️
...ation_tests/golden/golden_thing_admin_connection.h 100.00% <100.00%> (ø)
...en/internal/golden_kitchen_sink_connection_impl.cc 90.90% <100.00%> (ø)
...den/internal/golden_thing_admin_connection_impl.cc 94.44% <100.00%> (-0.03%) ⬇️
... and 14 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 223a6e0...0c68fb1. Read the comment docs.

@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 0c68fb10a7b18dc537deaff751aef8c62f77168e

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

@devbww devbww marked this pull request as ready for review January 29, 2022 08:34
@devbww devbww requested a review from a team as a code owner January 29, 2022 08:34
@devbww
Copy link
Contributor Author

devbww commented Jan 29, 2022

Don't bother looking at the "regenerated" commits.

Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

Thank you for separating the "generated" commits, made it much easier to review things.

Do you think it would be possible to add some sort of unit test to the generated golden files? We don't write tests for each generated library, and we explain this to ourselves by testing the golden files once. I am Okay we decide to add them in a separate PR.

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.

Thanks for doing the fix

@devbww
Copy link
Contributor Author

devbww commented Jan 29, 2022

Do you think it would be possible to add some sort of unit test to the generated golden files?

Yes, I'll look into it. Thanks.

@devbww devbww merged commit 9207865 into googleapis:main Jan 29, 2022
@devbww devbww deleted the connection-options branch January 29, 2022 18:56
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

Successfully merging this pull request may close these issues.

Merge connection options into client options, before defaulting the client options.
4 participants