diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index 5ab6619374345..974f331b9ee20 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -571,6 +571,7 @@ service { "ReadModifyWriteRow", "ReadRows", "SampleRowKeys", + "PingAndWarm", "PrepareQuery" ] omit_repo_metadata: true diff --git a/google/cloud/bigtable/internal/bigtable_auth_decorator.cc b/google/cloud/bigtable/internal/bigtable_auth_decorator.cc index 19f04976bea39..75619c26258a6 100644 --- a/google/cloud/bigtable/internal/bigtable_auth_decorator.cc +++ b/google/cloud/bigtable/internal/bigtable_auth_decorator.cc @@ -224,6 +224,27 @@ BigtableAuth::AsyncCheckAndMutateRow( }); } +future> +BigtableAuth::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + return auth_->AsyncConfigureContext(std::move(context)) + .then([cq, child = child_, options = std::move(options), + request](future>> + f) mutable { + auto context = f.get(); + if (!context) { + return make_ready_future( + StatusOr( + std::move(context).status())); + } + return child->AsyncPingAndWarm(cq, *std::move(context), + std::move(options), request); + }); +} + future> BigtableAuth::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_auth_decorator.h b/google/cloud/bigtable/internal/bigtable_auth_decorator.h index 08cb2328cd4fa..6118e588383e9 100644 --- a/google/cloud/bigtable/internal/bigtable_auth_decorator.h +++ b/google/cloud/bigtable/internal/bigtable_auth_decorator.h @@ -120,6 +120,12 @@ class BigtableAuth : public BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_channel_refresh.cc b/google/cloud/bigtable/internal/bigtable_channel_refresh.cc index 5e3cf133a8c2c..af3c6b754b301 100644 --- a/google/cloud/bigtable/internal/bigtable_channel_refresh.cc +++ b/google/cloud/bigtable/internal/bigtable_channel_refresh.cc @@ -139,6 +139,16 @@ BigtableChannelRefresh::AsyncCheckAndMutateRow( std::move(options), request); } +future> +BigtableChannelRefresh::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + return child_->AsyncPingAndWarm(cq, std::move(context), std::move(options), + request); +} + future> BigtableChannelRefresh::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_channel_refresh.h b/google/cloud/bigtable/internal/bigtable_channel_refresh.h index 7207b3c9f9aea..4c55ff34d0376 100644 --- a/google/cloud/bigtable/internal/bigtable_channel_refresh.h +++ b/google/cloud/bigtable/internal/bigtable_channel_refresh.h @@ -124,6 +124,12 @@ class BigtableChannelRefresh : public BigtableStub { google::cloud::internal::ImmutableOptions, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_logging_decorator.cc b/google/cloud/bigtable/internal/bigtable_logging_decorator.cc index f1119bb28c20e..07523e4b92c84 100644 --- a/google/cloud/bigtable/internal/bigtable_logging_decorator.cc +++ b/google/cloud/bigtable/internal/bigtable_logging_decorator.cc @@ -304,6 +304,24 @@ BigtableLogging::AsyncCheckAndMutateRow( tracing_options_); } +future> +BigtableLogging::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + return child_->AsyncPingAndWarm(cq, std::move(context), + std::move(options), request); + }, + cq, std::move(context), std::move(options), request, __func__, + tracing_options_); +} + future> BigtableLogging::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_logging_decorator.h b/google/cloud/bigtable/internal/bigtable_logging_decorator.h index d9badbe7a8397..5f5cf619a142d 100644 --- a/google/cloud/bigtable/internal/bigtable_logging_decorator.h +++ b/google/cloud/bigtable/internal/bigtable_logging_decorator.h @@ -120,6 +120,12 @@ class BigtableLogging : public BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_metadata_decorator.cc b/google/cloud/bigtable/internal/bigtable_metadata_decorator.cc index 60c974265a565..acc434bc39dc0 100644 --- a/google/cloud/bigtable/internal/bigtable_metadata_decorator.cc +++ b/google/cloud/bigtable/internal/bigtable_metadata_decorator.cc @@ -658,6 +658,42 @@ BigtableMetadata::AsyncCheckAndMutateRow( std::move(options), request); } +future> +BigtableMetadata::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + std::vector params; + params.reserve(2); + + static auto* name_matcher = [] { + return new google::cloud::internal::RoutingMatcher< + google::bigtable::v2::PingAndWarmRequest>{ + "name=", + { + {[](google::bigtable::v2::PingAndWarmRequest const& request) + -> std::string const& { return request.name(); }, + std::regex{"(projects/[^/]+/instances/[^/]+)", + std::regex::optimize}}, + }}; + }(); + name_matcher->AppendParam(request, params); + + if (!request.app_profile_id().empty()) { + params.push_back(absl::StrCat( + "app_profile_id=", internal::UrlEncode(request.app_profile_id()))); + } + + if (params.empty()) { + SetMetadata(*context, *options); + } else { + SetMetadata(*context, *options, absl::StrJoin(params, "&")); + } + return child_->AsyncPingAndWarm(cq, std::move(context), std::move(options), + request); +} + future> BigtableMetadata::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_metadata_decorator.h b/google/cloud/bigtable/internal/bigtable_metadata_decorator.h index 62833cd40c71d..70cf99b4a72e6 100644 --- a/google/cloud/bigtable/internal/bigtable_metadata_decorator.h +++ b/google/cloud/bigtable/internal/bigtable_metadata_decorator.h @@ -120,6 +120,12 @@ class BigtableMetadata : public BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_round_robin_decorator.cc b/google/cloud/bigtable/internal/bigtable_round_robin_decorator.cc index 529f757131695..00149b2b4d04d 100644 --- a/google/cloud/bigtable/internal/bigtable_round_robin_decorator.cc +++ b/google/cloud/bigtable/internal/bigtable_round_robin_decorator.cc @@ -152,6 +152,16 @@ BigtableRoundRobin::AsyncCheckAndMutateRow( std::move(options), request); } +future> +BigtableRoundRobin::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + return Child()->AsyncPingAndWarm(cq, std::move(context), std::move(options), + request); +} + future> BigtableRoundRobin::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_round_robin_decorator.h b/google/cloud/bigtable/internal/bigtable_round_robin_decorator.h index 5b7c9e2206e85..5d434d139c51b 100644 --- a/google/cloud/bigtable/internal/bigtable_round_robin_decorator.h +++ b/google/cloud/bigtable/internal/bigtable_round_robin_decorator.h @@ -118,6 +118,12 @@ class BigtableRoundRobin : public BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_stub.cc b/google/cloud/bigtable/internal/bigtable_stub.cc index d8b313019507c..f86035de2de67 100644 --- a/google/cloud/bigtable/internal/bigtable_stub.cc +++ b/google/cloud/bigtable/internal/bigtable_stub.cc @@ -229,6 +229,24 @@ DefaultBigtableStub::AsyncCheckAndMutateRow( request, std::move(context)); } +future> +DefaultBigtableStub::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + // NOLINTNEXTLINE(performance-unnecessary-value-param) + google::cloud::internal::ImmutableOptions, + google::bigtable::v2::PingAndWarmRequest const& request) { + return internal::MakeUnaryRpcImpl( + cq, + [this](grpc::ClientContext* context, + google::bigtable::v2::PingAndWarmRequest const& request, + grpc::CompletionQueue* cq) { + return grpc_stub_->AsyncPingAndWarm(context, request, cq); + }, + request, std::move(context)); +} + future> DefaultBigtableStub::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_stub.h b/google/cloud/bigtable/internal/bigtable_stub.h index 11fcb3cd985eb..3c101f57e4900 100644 --- a/google/cloud/bigtable/internal/bigtable_stub.h +++ b/google/cloud/bigtable/internal/bigtable_stub.h @@ -122,6 +122,12 @@ class BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) = 0; + virtual future> + AsyncPingAndWarm(google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) = 0; + virtual future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, @@ -222,6 +228,12 @@ class DefaultBigtableStub : public BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_tracing_stub.cc b/google/cloud/bigtable/internal/bigtable_tracing_stub.cc index 5e141b29e5621..80621c5222b38 100644 --- a/google/cloud/bigtable/internal/bigtable_tracing_stub.cc +++ b/google/cloud/bigtable/internal/bigtable_tracing_stub.cc @@ -234,6 +234,20 @@ BigtableTracingStub::AsyncCheckAndMutateRow( return internal::EndSpan(std::move(context), std::move(span), std::move(f)); } +future> +BigtableTracingStub::AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) { + auto span = + internal::MakeSpanGrpc("google.bigtable.v2.Bigtable", "PingAndWarm"); + internal::OTelScope scope(span); + internal::InjectTraceContext(*context, *propagator_); + auto f = child_->AsyncPingAndWarm(cq, context, std::move(options), request); + return internal::EndSpan(std::move(context), std::move(span), std::move(f)); +} + future> BigtableTracingStub::AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/internal/bigtable_tracing_stub.h b/google/cloud/bigtable/internal/bigtable_tracing_stub.h index 18f5eb2d3da27..c269361225ecb 100644 --- a/google/cloud/bigtable/internal/bigtable_tracing_stub.h +++ b/google/cloud/bigtable/internal/bigtable_tracing_stub.h @@ -118,6 +118,12 @@ class BigtableTracingStub : public BigtableStub { google::cloud::internal::ImmutableOptions options, google::bigtable::v2::CheckAndMutateRowRequest const& request) override; + future> AsyncPingAndWarm( + google::cloud::CompletionQueue& cq, + std::shared_ptr context, + google::cloud::internal::ImmutableOptions options, + google::bigtable::v2::PingAndWarmRequest const& request) override; + future> AsyncReadModifyWriteRow( google::cloud::CompletionQueue& cq, diff --git a/google/cloud/bigtable/testing/mock_bigtable_stub.h b/google/cloud/bigtable/testing/mock_bigtable_stub.h index 752780fe83a06..8e9ea4b398e97 100644 --- a/google/cloud/bigtable/testing/mock_bigtable_stub.h +++ b/google/cloud/bigtable/testing/mock_bigtable_stub.h @@ -111,6 +111,13 @@ class MockBigtableStub : public bigtable_internal::BigtableStub { google::cloud::internal::ImmutableOptions, google::bigtable::v2::CheckAndMutateRowRequest const&), (override)); + MOCK_METHOD(future>, + AsyncPingAndWarm, + (google::cloud::CompletionQueue&, + std::shared_ptr, + google::cloud::internal::ImmutableOptions, + google::bigtable::v2::PingAndWarmRequest const&), + (override)); MOCK_METHOD( future>, AsyncReadModifyWriteRow,