Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions generator/internal/client_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "absl/strings/str_replace.h"
#include "google/api/client.pb.h"
#include <google/protobuf/descriptor.h>
#include <absl/strings/match.h>

namespace google {
namespace cloud {
Expand Down Expand Up @@ -456,7 +457,10 @@ Status ClientGenerator::GenerateCc() {
if (MethodSignatureUsesDeprecatedField()) {
CcLocalIncludes({"google/cloud/internal/disable_deprecation_warnings.inc"});
}
CcLocalIncludes({vars("client_header_path")});
CcLocalIncludes({vars("client_header_path"),
absl::StartsWithIgnoreCase(vars("service_name"), "Bigtable")
? "google/cloud/bigtable/options.h"
: ""});
CcSystemIncludes({"memory"});
if (get_iam_policy_extension_ && set_iam_policy_extension_) {
CcLocalIncludes({vars("options_header_path")});
Expand All @@ -473,7 +477,7 @@ Status ClientGenerator::GenerateCc() {
CcPrint(R"""(
std::shared_ptr<$connection_class_name$> connection, Options opts)
: connection_(std::move(connection)),
options_(internal::MergeOptions(std::move(opts),
options_($merge_options_fn$(std::move(opts),
connection_->options())) {}
$client_class_name$::~$client_class_name$() = default;
)""");
Expand All @@ -488,7 +492,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
$response_type$>>
$client_class_name$::Async$method_name$(Options opts) {
internal::OptionsSpan span(
internal::MergeOptions(std::move(opts), options_));
$merge_options_fn$(std::move(opts), options_));
return connection_->Async$method_name$();
}
)""");
Expand All @@ -513,7 +517,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
{"\n$return_type$\n"},
// clang-format off
{method_string},
{" internal::OptionsSpan span(internal::MergeOptions("
{" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" $request_type$ request;\n"},
{method_request_string},
Expand All @@ -529,7 +533,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
"\nfuture<Status>\n",
"\nfuture<StatusOr<$longrunning_deduced_response_type$>>\n"},
{method_string},
{" internal::OptionsSpan span(internal::MergeOptions("
{" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" $request_type$ request;\n"},
{method_request_string},
Expand All @@ -541,7 +545,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
"\nStatus\n",
"\nStatusOr<$longrunning_operation_type$>\n"},
{start_method_string},
{" internal::OptionsSpan span(internal::MergeOptions("
{" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" $request_type$ request;\n"},
{method_request_string},
Expand All @@ -554,7 +558,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
// clang-format off
{"\nStreamRange<$range_output_type$>\n"},
{method_string},
{" internal::OptionsSpan span(internal::MergeOptions("
{" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" $request_type$ request;\n"},
{method_request_string},
Expand All @@ -567,7 +571,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
// clang-format off
{"\nStreamRange<$response_type$>\n"},
{method_string},
{" internal::OptionsSpan span(internal::MergeOptions("
{" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" $request_type$ request;\n"},
{method_request_string},
Expand All @@ -591,7 +595,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
" Options opts) {\n"
" internal::CheckExpectedOptions<$service_name$"
"BackoffPolicyOption>(opts, __func__);\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" "},
{ProtoNameToCppName(
Expand Down Expand Up @@ -644,7 +648,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
// clang-format off
{"$client_class_name$::$method_name$($request_type$ const& request"
", Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->$method_name$(request);\n"
"}\n"} // clang-format on
Expand All @@ -659,7 +663,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
"\nfuture<StatusOr<$longrunning_deduced_response_type$>>\n"},
{"$client_class_name$::$method_name$($request_type$ const& request"
", Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->$method_name$(request);\n"
"}\n"},
Expand All @@ -671,7 +675,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
{"$client_class_name$::$method_name$(NoAwaitTag"
", $request_type$ const& request"
", Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->$method_name$(NoAwaitTag{}, request);\n"
"}\n"},
Expand All @@ -682,7 +686,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
"\nfuture<StatusOr<$longrunning_deduced_response_type$>>\n"},
{"$client_class_name$::$method_name$("
"$longrunning_operation_type$ const& operation, Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->$method_name$(operation);\n"},
{"}\n"} // clang-format on
Expand All @@ -694,7 +698,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
{"\nStreamRange<$range_output_type$>\n"
"$client_class_name$::$method_name$($request_type$ request"
", Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->$method_name$(std::move(request));\n"
"}\n"} // clang-format on
Expand All @@ -706,7 +710,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
{"\nStreamRange<$response_type$>\n"
"$client_class_name$::$method_name$($request_type$ const& request"
", Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->$method_name$(request);\n"
"}\n"} // clang-format on
Expand All @@ -733,7 +737,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
{"\nfuture<$return_type$>\n"},
// clang-format off
{method_string},
{" internal::OptionsSpan span(internal::MergeOptions("
{" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"},
{" $request_type$ request;\n"},
{method_request_string},
Expand All @@ -752,7 +756,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
// clang-format off
{"$client_class_name$::Async$method_name$($request_type$ const& request"
", Options opts) {\n"
" internal::OptionsSpan span(internal::MergeOptions("
" internal::OptionsSpan span($merge_options_fn$("
"std::move(opts), options_));\n"
" return connection_->Async$method_name$(request);\n"
"}\n"} // clang-format on
Expand All @@ -768,7 +772,7 @@ std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
method.return_type(), R"""( $client_class_name$::)""", method.name(),
absl::StrReplaceAll(method.parameters(), {{" = {}", ""}}),
absl::StrFormat(R"""( {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
internal::OptionsSpan span($merge_options_fn$(std::move(opts), options_));
return connection_->%s(request);
}
)""",
Expand Down
4 changes: 4 additions & 0 deletions generator/internal/descriptor_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ VarsDictionary CreateServiceVars(
vars["logging_rest_header_path"] = absl::StrCat(
vars["product_path"], "internal/", ServiceNameToFilePath(service_name),
"_rest_logging_decorator.h");
vars["merge_options_fn"] =
absl::StartsWithIgnoreCase(service_name, "Bigtable")
? "bigtable_internal::MergeOptions"
: "internal::MergeOptions";
vars["metadata_class_name"] = absl::StrCat(service_name, "Metadata");
vars["metadata_cc_path"] = absl::StrCat(vars["product_path"], "internal/",
ServiceNameToFilePath(service_name),
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/bigtable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ add_library(
mutation_branch.h
mutations.cc
mutations.h
options.cc
options.h
polling_policy.cc
polling_policy.h
Expand Down Expand Up @@ -476,6 +477,7 @@ if (BUILD_TESTING)
mocks/mock_row_reader_test.cc
mutation_batcher_test.cc
mutations_test.cc
options_test.cc
polling_policy_test.cc
prepared_query_test.cc
query_row_test.cc
Expand Down
Loading
Loading