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
5 changes: 3 additions & 2 deletions generator/generator_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ message ServiceConfiguration {
repeated BespokeMethod bespoke_methods = 30;

// If set to `true`, the stub class methods will include an additional
// parameter of type `google::cloud::bigtable_internal::OperationContext&`.
bool experimental_bigtable_operation_context = 31;
// parameter of type
// `google::cloud::<product>_internal::OperationContext&`.
bool experimental_operation_context = 31;
}

message DiscoveryDocumentDefinedProduct {
Expand Down
2 changes: 1 addition & 1 deletion generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ service {
omit_connection: true
omit_stub_factory: true
generate_round_robin_decorator: true
experimental_bigtable_operation_context: true
experimental_operation_context: true
omitted_rpcs: [
"GenerateInitialChangeStreamPartitions",
"ReadChangeStream"
Expand Down
8 changes: 4 additions & 4 deletions generator/internal/codegen_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ TEST(ProcessCommandLineArgs, ProcessExperimental) {
EXPECT_THAT(*result, Contains(Pair("experimental", "true")));
}

TEST(ProcessCommandLineArgs, ProcessExperimentalBigtableOperationContext) {
TEST(ProcessCommandLineArgs, ProcessExperimentalOperationContext) {
auto result = ProcessCommandLineArgs(
"product_path=google/cloud/bigtable/"
",experimental_bigtable_operation_context=true");
",experimental_operation_context=true");
ASSERT_THAT(result, IsOk());
EXPECT_THAT(*result, Contains(Pair("experimental_bigtable_operation_context",
"true")));
EXPECT_THAT(*result,
Contains(Pair("experimental_operation_context", "true")));
}

TEST(ProcessCommandLineArgs, ProcessServiceNameMapping) {
Expand Down
22 changes: 10 additions & 12 deletions generator/internal/descriptor_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,27 +850,25 @@ VarsDictionary CreateServiceVars(
SetRetryStatusCodeExpression(vars);
vars["transient_errors_comment"] = TransientErrorsComment(vars);
SetLongrunningOperationServiceVars(descriptor, vars);
auto const experimental_bigtable_operation_context =
vars.find("experimental_bigtable_operation_context");
if (experimental_bigtable_operation_context != vars.end() &&
experimental_bigtable_operation_context->second == "true") {
auto const experimental_operation_context =
vars.find("experimental_operation_context");
if (experimental_operation_context != vars.end() &&
experimental_operation_context->second == "true") {
auto const& ns = vars.find("product_internal_namespace")->second;
Comment thread
scotthart marked this conversation as resolved.
vars["op_ctx_decl"] =
",\n google::cloud::bigtable_internal::OperationContext& "
"operation_context";
absl::StrCat(",\n ", ns, "::OperationContext& operation_context");
vars["op_ctx_arg"] = ", operation_context";
vars["op_ctx_cap"] = ", &operation_context";
vars["op_ctx_stub_decl"] =
",\n google::cloud::bigtable_internal::OperationContext&";
absl::StrCat(",\n ", ns, "::OperationContext&");
vars["op_ctx_shared_decl"] =
",\n "
"std::shared_ptr<google::cloud::bigtable_internal::OperationContext> "
"operation_context";
absl::StrCat(",\n std::shared_ptr<", ns,
"::OperationContext> operation_context");
vars["op_ctx_shared_arg"] = ", std::move(operation_context)";
vars["op_ctx_shared_cap"] =
", operation_context = std::move(operation_context)";
vars["op_ctx_shared_stub_decl"] =
",\n "
"std::shared_ptr<google::cloud::bigtable_internal::OperationContext>";
absl::StrCat(",\n std::shared_ptr<", ns, "::OperationContext>");
} else {
vars["op_ctx_decl"] = "";
vars["op_ctx_arg"] = "";
Expand Down
4 changes: 2 additions & 2 deletions generator/internal/service_code_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ bool ServiceCodeGenerator::IsExperimental() const {
return iter != vars().end() && iter->second == "true";
}

bool ServiceCodeGenerator::HasExperimentalBigtableOperationContext() const {
auto iter = vars().find("experimental_bigtable_operation_context");
bool ServiceCodeGenerator::HasExperimentalOperationContext() const {
auto iter = vars().find("experimental_operation_context");
return iter != vars().end() && iter->second == "true";
}

Expand Down
4 changes: 2 additions & 2 deletions generator/internal/service_code_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class ServiceCodeGenerator : public GeneratorInterface {
bool IsExperimental() const;

/**
* Determines if the service enables experimental Bigtable OperationContext.
* Determines if the service enables experimental OperationContext.
*/
bool HasExperimentalBigtableOperationContext() const;
bool HasExperimentalOperationContext() const;

/**
* Determines if the service contains at least one method that requires
Expand Down
8 changes: 4 additions & 4 deletions generator/internal/stub_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ Status StubGenerator::GenerateHeader() {
HeaderProtobufGenCodeIncludes(
{vars("proto_grpc_header_path"),
include_lro_header ? "google/longrunning/operations.grpc.pb.h" : ""});
HeaderLocalIncludes(
{HasExperimentalOperationContext()
? absl::StrCat(vars("product_path"), "internal/operation_context.h")
: ""});
HeaderSystemIncludes({"memory", "utility"});
Comment thread
scotthart marked this conversation as resolved.
HeaderGrpcPortsDefInclude();
auto result = HeaderOpenNamespaces(NamespaceType::kInternal);
if (!result.ok()) return result;

if (HasExperimentalBigtableOperationContext()) {
HeaderPrint("\nclass OperationContext;\n");
}

// Abstract interface Stub base class
Comment thread
scotthart marked this conversation as resolved.
HeaderPrint( // clang-format off
"\n"
Expand Down
4 changes: 2 additions & 2 deletions generator/standalone_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ std::vector<std::future<google::cloud::Status>> GenerateCodeFromProtos(
args.emplace_back(
"--cpp_codegen_opt=generate_round_robin_decorator=true");
}
if (service.experimental_bigtable_operation_context()) {
if (service.experimental_operation_context()) {
args.emplace_back(
"--cpp_codegen_opt=experimental_bigtable_operation_context=true");
"--cpp_codegen_opt=experimental_operation_context=true");
}
args.emplace_back("--cpp_codegen_opt=service_endpoint_env_var=" +
service.service_endpoint_env_var());
Expand Down
57 changes: 21 additions & 36 deletions google/cloud/bigtable/internal/bigtable_auth_decorator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ std::unique_ptr<google::cloud::internal::StreamingReadRpc<
BigtableAuth::ReadRows(
std::shared_ptr<grpc::ClientContext> context, Options const& options,
google::bigtable::v2::ReadRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using ErrorStream = ::google::cloud::internal::StreamingReadRpcError<
google::bigtable::v2::ReadRowsResponse>;
auto status = auth_->ConfigureContext(*context);
Expand All @@ -56,8 +55,7 @@ std::unique_ptr<google::cloud::internal::StreamingReadRpc<
BigtableAuth::SampleRowKeys(
std::shared_ptr<grpc::ClientContext> context, Options const& options,
google::bigtable::v2::SampleRowKeysRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using ErrorStream = ::google::cloud::internal::StreamingReadRpcError<
google::bigtable::v2::SampleRowKeysResponse>;
auto status = auth_->ConfigureContext(*context);
Expand All @@ -69,7 +67,7 @@ BigtableAuth::SampleRowKeys(
StatusOr<google::bigtable::v2::MutateRowResponse> BigtableAuth::MutateRow(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::MutateRowRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
bigtable_internal::OperationContext& operation_context) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->MutateRow(context, options, request, operation_context);
Expand All @@ -80,8 +78,7 @@ std::unique_ptr<google::cloud::internal::StreamingReadRpc<
BigtableAuth::MutateRows(
std::shared_ptr<grpc::ClientContext> context, Options const& options,
google::bigtable::v2::MutateRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using ErrorStream = ::google::cloud::internal::StreamingReadRpcError<
google::bigtable::v2::MutateRowsResponse>;
auto status = auth_->ConfigureContext(*context);
Expand All @@ -94,7 +91,7 @@ StatusOr<google::bigtable::v2::CheckAndMutateRowResponse>
BigtableAuth::CheckAndMutateRow(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::CheckAndMutateRowRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
bigtable_internal::OperationContext& operation_context) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->CheckAndMutateRow(context, options, request,
Expand All @@ -104,7 +101,7 @@ BigtableAuth::CheckAndMutateRow(
StatusOr<google::bigtable::v2::PingAndWarmResponse> BigtableAuth::PingAndWarm(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::PingAndWarmRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
bigtable_internal::OperationContext& operation_context) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->PingAndWarm(context, options, request, operation_context);
Expand All @@ -114,7 +111,7 @@ StatusOr<google::bigtable::v2::ReadModifyWriteRowResponse>
BigtableAuth::ReadModifyWriteRow(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::ReadModifyWriteRowRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
bigtable_internal::OperationContext& operation_context) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->ReadModifyWriteRow(context, options, request,
Expand All @@ -124,7 +121,7 @@ BigtableAuth::ReadModifyWriteRow(
StatusOr<google::bigtable::v2::PrepareQueryResponse> BigtableAuth::PrepareQuery(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::PrepareQueryRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
bigtable_internal::OperationContext& operation_context) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->PrepareQuery(context, options, request, operation_context);
Expand All @@ -135,8 +132,7 @@ std::unique_ptr<google::cloud::internal::StreamingReadRpc<
BigtableAuth::ExecuteQuery(
std::shared_ptr<grpc::ClientContext> context, Options const& options,
google::bigtable::v2::ExecuteQueryRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using ErrorStream = ::google::cloud::internal::StreamingReadRpcError<
google::bigtable::v2::ExecuteQueryResponse>;
auto status = auth_->ConfigureContext(*context);
Expand All @@ -149,7 +145,7 @@ StatusOr<google::bigtable::v2::ClientConfiguration>
BigtableAuth::GetClientConfiguration(
grpc::ClientContext& context, Options const& options,
google::bigtable::v2::GetClientConfigurationRequest const& request,
google::cloud::bigtable_internal::OperationContext& operation_context) {
bigtable_internal::OperationContext& operation_context) {
auto status = auth_->ConfigureContext(context);
if (!status.ok()) return status;
return child_->GetClientConfiguration(context, options, request,
Expand All @@ -163,8 +159,7 @@ BigtableAuth::AsyncOpenTable(
google::cloud::CompletionQueue const& cq,
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using StreamAuth = google::cloud::internal::AsyncStreamingReadWriteRpcAuth<
google::bigtable::v2::SessionRequest,
google::bigtable::v2::SessionResponse>;
Expand All @@ -186,8 +181,7 @@ BigtableAuth::AsyncOpenAuthorizedView(
google::cloud::CompletionQueue const& cq,
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using StreamAuth = google::cloud::internal::AsyncStreamingReadWriteRpcAuth<
google::bigtable::v2::SessionRequest,
google::bigtable::v2::SessionResponse>;
Expand All @@ -209,8 +203,7 @@ BigtableAuth::AsyncOpenMaterializedView(
google::cloud::CompletionQueue const& cq,
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using StreamAuth = google::cloud::internal::AsyncStreamingReadWriteRpcAuth<
google::bigtable::v2::SessionRequest,
google::bigtable::v2::SessionResponse>;
Expand All @@ -232,8 +225,7 @@ BigtableAuth::AsyncReadRows(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::ReadRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using StreamAuth = google::cloud::internal::AsyncStreamingReadRpcAuth<
google::bigtable::v2::ReadRowsResponse>;

Expand All @@ -255,8 +247,7 @@ BigtableAuth::AsyncSampleRowKeys(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::SampleRowKeysRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using StreamAuth = google::cloud::internal::AsyncStreamingReadRpcAuth<
google::bigtable::v2::SampleRowKeysResponse>;

Expand All @@ -277,8 +268,7 @@ BigtableAuth::AsyncMutateRow(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::MutateRowRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
return auth_->AsyncConfigureContext(std::move(context))
.then([cq, child = child_, options = std::move(options), request,
operation_context = std::move(operation_context)](
Expand All @@ -303,8 +293,7 @@ BigtableAuth::AsyncMutateRows(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::MutateRowsRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
using StreamAuth = google::cloud::internal::AsyncStreamingReadRpcAuth<
google::bigtable::v2::MutateRowsResponse>;

Expand All @@ -325,8 +314,7 @@ BigtableAuth::AsyncCheckAndMutateRow(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::CheckAndMutateRowRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
return auth_->AsyncConfigureContext(std::move(context))
.then([cq, child = child_, options = std::move(options), request,
operation_context = std::move(operation_context)](
Expand All @@ -350,8 +338,7 @@ BigtableAuth::AsyncPingAndWarm(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::PingAndWarmRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
return auth_->AsyncConfigureContext(std::move(context))
.then([cq, child = child_, options = std::move(options), request,
operation_context = std::move(operation_context)](
Expand All @@ -375,8 +362,7 @@ BigtableAuth::AsyncReadModifyWriteRow(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::ReadModifyWriteRowRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
return auth_->AsyncConfigureContext(std::move(context))
.then([cq, child = child_, options = std::move(options), request,
operation_context = std::move(operation_context)](
Expand All @@ -400,8 +386,7 @@ BigtableAuth::AsyncPrepareQuery(
std::shared_ptr<grpc::ClientContext> context,
google::cloud::internal::ImmutableOptions options,
google::bigtable::v2::PrepareQueryRequest const& request,
std::shared_ptr<google::cloud::bigtable_internal::OperationContext>
operation_context) {
std::shared_ptr<bigtable_internal::OperationContext> operation_context) {
return auth_->AsyncConfigureContext(std::move(context))
.then([cq, child = child_, options = std::move(options), request,
operation_context = std::move(operation_context)](
Expand Down
Loading
Loading