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(common): QuotaUserOption for gRPC-based libs #13933

Merged
merged 2 commits into from
Apr 7, 2024

Conversation

coryan
Copy link
Member

@coryan coryan commented Apr 5, 2024

Fixes #13928


This change is Reviewable

@@ -31,6 +32,12 @@ void ConfigureContext(grpc::ClientContext& context, Options const& opts) {
context.set_compression_algorithm(
opts.get<GrpcCompressionAlgorithmOption>());
}
if (opts.has<UserIpOption>() && !opts.has<QuotaUserOption>()) {
Copy link
Member

Choose a reason for hiding this comment

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

Putting this in the metadata decorator would be more consistent:

if (options.has<UserProjectOption>()) {
context.AddMetadata("x-goog-user-project",
options.get<UserProjectOption>());
}
auto const& authority = options.get<AuthorityOption>();
if (!authority.empty()) context.set_authority(authority);
for (auto const& h : options.get<CustomHeadersOption>()) {
context.AddMetadata(h.first, h.second);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm... if anything, the metadata decorator should not set these common options and just call a common function to do it.

Copy link
Member

@dbolduc dbolduc Apr 5, 2024

Choose a reason for hiding this comment

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

if anything, the metadata decorator should not set these common options and just call a common function to do it.

Sure, that will save us N lines of code per service.


I sort of think that the base stub should call ConfigureContext(), instead of the retry loops calling it.

Part of the reason why I would steer you away from ConfigureContext() is that I don't trust its coverage. For example, the polling loops do not use it:

ConfigurePollContext(*context, *options_);

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's merge #13935 and then I can make the changes to that function, would that work?

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL.

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.12%. Comparing base (18f522e) to head (a694a5b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13933   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files        2181     2181           
  Lines      185840   185870   +30     
=======================================
+ Hits       173065   173098   +33     
+ Misses      12775    12772    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coryan coryan force-pushed the feat-common-quota-user-for-gRPC branch from 6d428bb to 404cd19 Compare April 6, 2024 12:45
@coryan coryan marked this pull request as ready for review April 6, 2024 19:13
@coryan coryan requested a review from a team as a code owner April 6, 2024 19:13
*
* This can be used to separate quota usage by source IP address.
*
* @deprecated prefer using `google::cloud::QuotaUser`.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/QuotaUser/QuotaUserOption/?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@coryan coryan merged commit b839355 into googleapis:main Apr 7, 2024
62 checks passed
@coryan coryan deleted the feat-common-quota-user-for-gRPC branch April 7, 2024 17:14
};

/**
* Configure the UserIp system parameter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Was "system parameter" supposed to be a link?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, fixed in #13937

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.

Refactor QuotaUserOption to common options
3 participants