Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthart committed Mar 22, 2024
1 parent c9e0bb7 commit 4498caa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 2 additions & 4 deletions generator/internal/metadata_decorator_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,8 @@ void $metadata_class_name$::SetMetadata(grpc::ClientContext& context,
}
auto const& authority = options.get<AuthorityOption>();
if (!authority.empty()) context.set_authority(authority);
if (options.has<google::cloud::CustomHeadersOption>()) {
for (auto const& h : options.get<google::cloud::CustomHeadersOption>()) {
context.AddMetadata(h.first, h.second);
}
for (auto const& h : options.get<CustomHeadersOption>()) {
context.AddMetadata(h.first, h.second);
}
}
)""");
Expand Down
14 changes: 6 additions & 8 deletions generator/internal/metadata_decorator_rest_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,21 +389,19 @@ void $metadata_rest_class_name$::SetMetadata(
rest_context.AddHeader(
"x-goog-user-project", options.get<UserProjectOption>());
}
if (options.has<google::cloud::QuotaUserOption>()) {
if (options.has<QuotaUserOption>()) {
rest_context.AddHeader(
"x-goog-quota-user", options.get<google::cloud::QuotaUserOption>());
"x-goog-quota-user", options.get<QuotaUserOption>());
}
if (options.has<google::cloud::ServerTimeoutOption>()) {
if (options.has<ServerTimeoutOption>()) {
auto ms_rep = absl::StrCat(
absl::Dec(options.get<google::cloud::ServerTimeoutOption>().count(),
absl::Dec(options.get<ServerTimeoutOption>().count(),
absl::kZeroPad4));
rest_context.AddHeader("x-server-timeout",
ms_rep.insert(ms_rep.size() - 3, "."));
}
if (options.has<google::cloud::CustomHeadersOption>()) {
for (auto const& h : options.get<google::cloud::CustomHeadersOption>()) {
rest_context.AddHeader(h.first, h.second);
}
for (auto const& h : options.get<CustomHeadersOption>()) {
rest_context.AddHeader(h.first, h.second);
}
}
)""");
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/common_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ struct UserAgentProductsOption {
*
* - rpc
* - rpc-streams
*
* @ingroup options
*/
struct TracingComponentsOption {
using Type = std::set<std::string>;
Expand Down Expand Up @@ -223,6 +225,8 @@ struct ProxyOption {
*
* For example, the server may know it is safe to retry a non-idempotent
* request, or safe to retry a status code that is typically a permanent error.
*
* @ingroup options
*/
struct EnableServerRetriesOption {
using Type = bool;
Expand All @@ -233,6 +237,8 @@ struct EnableServerRetriesOption {
*
* For REST endpoints, these headers are added to the HTTP headers. For gRPC
* endpoints, these headers are added to the `grpc::ClientContext` metadata.
*
* @ingroup options
*/
struct CustomHeadersOption {
using Type = std::unordered_multimap<std::string, std::string>;
Expand Down

0 comments on commit 4498caa

Please sign in to comment.