summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-04-09 01:21:00 +0300
committerrobot-piglet <[email protected]>2026-04-09 01:51:01 +0300
commit8b606c1cb8b52fceea3389eb37cf6e2bc03dc8f7 (patch)
tree7bc31bbff5b6b97285777da2a14804b5031106a5
parentf1d1502648b4322e2bd8b17d5a0acb3c9c336ccf (diff)
Intermediate changes
commit_hash:76db5b7b9603e9e5fc9ff87d2d98c79b83742b0a
-rw-r--r--contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h12
-rw-r--r--contrib/libs/grpc/patches/32-revert-upstream-3ed72c0c60c2e6ba3cb68d1cf9df67b623736282.patch487
-rw-r--r--contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc124
-rw-r--r--contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h107
-rw-r--r--contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc31
5 files changed, 166 insertions, 595 deletions
diff --git a/contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h b/contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h
index 64db3bda495..43a19900959 100644
--- a/contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h
+++ b/contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h
@@ -19,11 +19,15 @@
#ifndef GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
#define GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
+#include <memory>
+
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/config.h>
namespace grpc {
class ProtoServerReflection;
+class ProtoServerReflectionBackend;
+class ProtoServerReflectionV1;
class ServerInitializer;
namespace reflection {
@@ -31,15 +35,17 @@ namespace reflection {
class ProtoServerReflectionPlugin : public grpc::ServerBuilderPlugin {
public:
ProtoServerReflectionPlugin();
- TString name() override;
+ ::TString name() override;
void InitServer(ServerInitializer* si) override;
void Finish(ServerInitializer* si) override;
- void ChangeArguments(const TString& name, void* value) override;
+ void ChangeArguments(const ::TString& name, void* value) override;
bool has_async_methods() const override;
bool has_sync_methods() const override;
private:
- std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;
+ std::shared_ptr<grpc::ProtoServerReflectionBackend> backend_;
+ std::shared_ptr<grpc::ProtoServerReflection> reflection_service_v1alpha_;
+ std::shared_ptr<grpc::ProtoServerReflectionV1> reflection_service_v1_;
};
/// Add proto reflection plugin to \a ServerBuilder.
diff --git a/contrib/libs/grpc/patches/32-revert-upstream-3ed72c0c60c2e6ba3cb68d1cf9df67b623736282.patch b/contrib/libs/grpc/patches/32-revert-upstream-3ed72c0c60c2e6ba3cb68d1cf9df67b623736282.patch
deleted file mode 100644
index a35a4bcb40f..00000000000
--- a/contrib/libs/grpc/patches/32-revert-upstream-3ed72c0c60c2e6ba3cb68d1cf9df67b623736282.patch
+++ /dev/null
@@ -1,487 +0,0 @@
-commit 3f1601dbf9160951f00fa9c173d5878d97719032
-author: nechda
-date: 2026-02-19T13:29:59+03:00
-
- revert upstream commit 3ed72c0c60c2e6ba3cb68d1cf9df67b623736282
-
- This commit reverts changes that apper in upstream's commit 3ed72c0c60c2e6ba3cb68d1cf9df67b623736282
- [reflection] Add v1 reflection (#34599)
-
---- contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h (d9e6a4052b262a203f1761906f0927c2cac29938)
-+++ contrib/libs/grpc/include/grpcpp/ext/proto_server_reflection_plugin.h (3f1601dbf9160951f00fa9c173d5878d97719032)
-@@ -19,15 +19,11 @@
- #ifndef GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
- #define GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
-
--#include <memory>
--
- #include <grpcpp/impl/server_builder_plugin.h>
- #include <grpcpp/support/config.h>
-
- namespace grpc {
- class ProtoServerReflection;
--class ProtoServerReflectionBackend;
--class ProtoServerReflectionV1;
- class ServerInitializer;
-
- namespace reflection {
-@@ -35,17 +31,15 @@ namespace reflection {
- class ProtoServerReflectionPlugin : public grpc::ServerBuilderPlugin {
- public:
- ProtoServerReflectionPlugin();
-- ::TString name() override;
-+ TString name() override;
- void InitServer(ServerInitializer* si) override;
- void Finish(ServerInitializer* si) override;
-- void ChangeArguments(const ::TString& name, void* value) override;
-+ void ChangeArguments(const TString& name, void* value) override;
- bool has_async_methods() const override;
- bool has_sync_methods() const override;
-
- private:
-- std::shared_ptr<grpc::ProtoServerReflectionBackend> backend_;
-- std::shared_ptr<grpc::ProtoServerReflection> reflection_service_v1alpha_;
-- std::shared_ptr<grpc::ProtoServerReflectionV1> reflection_service_v1_;
-+ std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;
- };
-
- /// Add proto reflection plugin to \a ServerBuilder.
---- contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc (d9e6a4052b262a203f1761906f0927c2cac29938)
-+++ contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc (3f1601dbf9160951f00fa9c173d5878d97719032)
-@@ -23,41 +23,58 @@
-
- #include <grpcpp/grpcpp.h>
- #include <grpcpp/support/interceptor.h>
--#include <grpcpp/support/sync_stream.h>
-
- // IWYU pragma: no_include "google/protobuf/descriptor.h"
- // IWYU pragma: no_include <google/protobuf/descriptor.h>
--// IWYU pragma: no_include "src/proto/grpc/reflection/v1/reflection.pb.h"
--// IWYU pragma: no_include "src/proto/grpc/reflection/v1alpha/reflection.pb.h"
-+
-+using grpc::reflection::v1alpha::ErrorResponse;
-+using grpc::reflection::v1alpha::ExtensionNumberResponse;
-+using grpc::reflection::v1alpha::ExtensionRequest;
-+using grpc::reflection::v1alpha::ListServiceResponse;
-+using grpc::reflection::v1alpha::ServerReflectionRequest;
-+using grpc::reflection::v1alpha::ServerReflectionResponse;
-+using grpc::reflection::v1alpha::ServiceResponse;
-
- namespace grpc {
-
--template <typename Request, typename Response>
--Status ProtoServerReflectionBackend::ServerReflectionInfo(
-- ServerReaderWriter<Response, Request>* stream) const {
-- Request request;
-- Response response;
-+ProtoServerReflection::ProtoServerReflection()
-+ : descriptor_pool_(protobuf::DescriptorPool::generated_pool()) {}
-+
-+void ProtoServerReflection::SetServiceList(
-+ const std::vector<TString>* services) {
-+ services_ = services;
-+}
-+
-+Status ProtoServerReflection::ServerReflectionInfo(
-+ ServerContext* context,
-+ ServerReaderWriter<ServerReflectionResponse, ServerReflectionRequest>*
-+ stream) {
-+ ServerReflectionRequest request;
-+ ServerReflectionResponse response;
- Status status;
- while (stream->Read(&request)) {
- switch (request.message_request_case()) {
-- case Request::MessageRequestCase::kFileByFilename:
-- status = GetFileByName(request.file_by_filename(), &response);
-+ case ServerReflectionRequest::MessageRequestCase::kFileByFilename:
-+ status = GetFileByName(context, request.file_by_filename(), &response);
- break;
-- case Request::MessageRequestCase::kFileContainingSymbol:
-- status = GetFileContainingSymbol(request.file_containing_symbol(),
-- &response);
-+ case ServerReflectionRequest::MessageRequestCase::kFileContainingSymbol:
-+ status = GetFileContainingSymbol(
-+ context, request.file_containing_symbol(), &response);
- break;
-- case Request::MessageRequestCase::kFileContainingExtension:
-+ case ServerReflectionRequest::MessageRequestCase::
-+ kFileContainingExtension:
- status = GetFileContainingExtension(
-- &request.file_containing_extension(), &response);
-+ context, &request.file_containing_extension(), &response);
- break;
-- case Request::MessageRequestCase::kAllExtensionNumbersOfType:
-+ case ServerReflectionRequest::MessageRequestCase::
-+ kAllExtensionNumbersOfType:
- status = GetAllExtensionNumbers(
-- request.all_extension_numbers_of_type(),
-+ context, request.all_extension_numbers_of_type(),
- response.mutable_all_extension_numbers_response());
- break;
-- case Request::MessageRequestCase::kListServices:
-- status = ListService(response.mutable_list_services_response());
-+ case ServerReflectionRequest::MessageRequestCase::kListServices:
-+ status =
-+ ListService(context, response.mutable_list_services_response());
- break;
- default:
- status = Status(StatusCode::UNIMPLEMENTED, "");
-@@ -67,40 +84,41 @@ Status ProtoServerReflectionBackend::ServerReflectionInfo(
- FillErrorResponse(status, response.mutable_error_response());
- }
- response.set_valid_host(request.host());
-- response.set_allocated_original_request(new Request(request));
-+ response.set_allocated_original_request(
-+ new ServerReflectionRequest(request));
- stream->Write(response);
- }
-+
- return Status::OK;
- }
-
--template <typename Response>
--void ProtoServerReflectionBackend::FillErrorResponse(
-- const Status& status, Response* error_response) const {
-+void ProtoServerReflection::FillErrorResponse(const Status& status,
-+ ErrorResponse* error_response) {
- error_response->set_error_code(status.error_code());
- error_response->set_error_message(status.error_message());
- }
-
--template <typename Response>
--Status ProtoServerReflectionBackend::ListService(Response* response) const {
-+Status ProtoServerReflection::ListService(ServerContext* /*context*/,
-+ ListServiceResponse* response) {
- if (services_ == nullptr) {
- return Status(StatusCode::NOT_FOUND, "Services not found.");
- }
- for (const auto& value : *services_) {
-- auto* service_response = response->add_service();
-+ ServiceResponse* service_response = response->add_service();
- service_response->set_name(value);
- }
- return Status::OK;
- }
-
--template <typename Response>
--Status ProtoServerReflectionBackend::GetFileByName(const TString& file_name,
-- Response* response) const {
-+Status ProtoServerReflection::GetFileByName(
-+ ServerContext* /*context*/, const TString& file_name,
-+ ServerReflectionResponse* response) {
- if (descriptor_pool_ == nullptr) {
- return Status::CANCELLED;
- }
-
- const protobuf::FileDescriptor* file_desc =
-- descriptor_pool_->FindFileByName(TProtoStringType(file_name));
-+ descriptor_pool_->FindFileByName(file_name);
- if (file_desc == nullptr) {
- return Status(StatusCode::NOT_FOUND, "File not found.");
- }
-@@ -109,15 +127,15 @@ Status ProtoServerReflectionBackend::GetFileByName(const TString& file_name,
- return Status::OK;
- }
-
--template <typename Response>
--Status ProtoServerReflectionBackend::GetFileContainingSymbol(
-- const TString& symbol, Response* response) const {
-+Status ProtoServerReflection::GetFileContainingSymbol(
-+ ServerContext* /*context*/, const TString& symbol,
-+ ServerReflectionResponse* response) {
- if (descriptor_pool_ == nullptr) {
- return Status::CANCELLED;
- }
-
- const protobuf::FileDescriptor* file_desc =
-- descriptor_pool_->FindFileContainingSymbol(TProtoStringType(symbol));
-+ descriptor_pool_->FindFileContainingSymbol(symbol);
- if (file_desc == nullptr) {
- return Status(StatusCode::NOT_FOUND, "Symbol not found.");
- }
-@@ -126,9 +144,9 @@ Status ProtoServerReflectionBackend::GetFileContainingSymbol(
- return Status::OK;
- }
-
--template <typename Request, typename Response>
--Status ProtoServerReflectionBackend::GetFileContainingExtension(
-- const Request* request, Response* response) const {
-+Status ProtoServerReflection::GetFileContainingExtension(
-+ ServerContext* /*context*/, const ExtensionRequest* request,
-+ ServerReflectionResponse* response) {
- if (descriptor_pool_ == nullptr) {
- return Status::CANCELLED;
- }
-@@ -150,15 +168,15 @@ Status ProtoServerReflectionBackend::GetFileContainingExtension(
- return Status::OK;
- }
-
--template <typename Response>
--Status ProtoServerReflectionBackend::GetAllExtensionNumbers(
-- const TString& type, Response* response) const {
-+Status ProtoServerReflection::GetAllExtensionNumbers(
-+ ServerContext* /*context*/, const TString& type,
-+ ExtensionNumberResponse* response) {
- if (descriptor_pool_ == nullptr) {
- return Status::CANCELLED;
- }
-
- const protobuf::Descriptor* desc =
-- descriptor_pool_->FindMessageTypeByName(TProtoStringType(type));
-+ descriptor_pool_->FindMessageTypeByName(type);
- if (desc == nullptr) {
- return Status(StatusCode::NOT_FOUND, "Type not found.");
- }
-@@ -172,17 +190,17 @@ Status ProtoServerReflectionBackend::GetAllExtensionNumbers(
- return Status::OK;
- }
-
--template <typename Response>
--void ProtoServerReflectionBackend::FillFileDescriptorResponse(
-- const protobuf::FileDescriptor* file_desc, Response* response,
-- std::unordered_set<TString>* seen_files) const {
-+void ProtoServerReflection::FillFileDescriptorResponse(
-+ const protobuf::FileDescriptor* file_desc,
-+ ServerReflectionResponse* response,
-+ std::unordered_set<TString>* seen_files) {
- if (seen_files->find(file_desc->name()) != seen_files->end()) {
- return;
- }
- seen_files->insert(file_desc->name());
-
- protobuf::FileDescriptorProto file_desc_proto;
-- TProtoStringType data;
-+ TString data;
- file_desc->CopyTo(&file_desc_proto);
- file_desc_proto.SerializeToString(&data);
- response->mutable_file_descriptor_response()->add_file_descriptor_proto(data);
-@@ -192,18 +210,4 @@ void ProtoServerReflectionBackend::FillFileDescriptorResponse(
- }
- }
-
--Status ProtoServerReflection::ServerReflectionInfo(
-- ServerContext* /* context */,
-- ServerReaderWriter<reflection::v1alpha::ServerReflectionResponse,
-- reflection::v1alpha::ServerReflectionRequest>* stream) {
-- return backend_->ServerReflectionInfo(stream);
--}
--
--Status ProtoServerReflectionV1::ServerReflectionInfo(
-- ServerContext* /* context */,
-- ServerReaderWriter<reflection::v1::ServerReflectionResponse,
-- reflection::v1::ServerReflectionRequest>* stream) {
-- return backend_->ServerReflectionInfo(stream);
--}
--
- } // namespace grpc
---- contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h (d9e6a4052b262a203f1761906f0927c2cac29938)
-+++ contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h (3f1601dbf9160951f00fa9c173d5878d97719032)
-@@ -19,11 +19,8 @@
- #ifndef GRPC_SRC_CPP_EXT_PROTO_SERVER_REFLECTION_H
- #define GRPC_SRC_CPP_EXT_PROTO_SERVER_REFLECTION_H
-
--#include <memory>
--#include <util/generic/string.h>
--#include <util/string/cast.h>
-+#include <string>
- #include <unordered_set>
--#include <utility>
- #include <vector>
-
- #include <grpcpp/grpcpp.h>
-@@ -32,72 +29,18 @@
- #include <grpcpp/support/status.h>
- #include <grpcpp/support/sync_stream.h>
-
--#include "src/proto/grpc/reflection/v1/reflection.grpc.pb.h"
--#include "src/proto/grpc/reflection/v1/reflection.pb.h"
- #include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h"
- #include "src/proto/grpc/reflection/v1alpha/reflection.pb.h"
-
- namespace grpc {
-
--class ProtoServerReflectionBackend {
-- public:
-- ProtoServerReflectionBackend()
-- : descriptor_pool_(protobuf::DescriptorPool::generated_pool()) {}
--
-- void SetServiceList(const std::vector<TString>* services) {
-- services_ = services;
-- }
--
-- template <typename Request, typename Response>
-- Status ServerReflectionInfo(
-- ServerReaderWriter<Response, Request>* stream) const;
--
-- private:
-- template <typename Response>
-- Status ListService(Response* response) const;
--
-- template <typename Response>
-- Status GetFileByName(const TString& file_name, Response* response) const;
--
-- template <typename Response>
-- Status GetFileContainingSymbol(const TString& symbol,
-- Response* response) const;
--
-- template <typename Request, typename Response>
-- Status GetFileContainingExtension(const Request* request,
-- Response* response) const;
--
-- template <typename Response>
-- Status GetAllExtensionNumbers(const TString& type,
-- Response* response) const;
--
-- template <typename Response>
-- void FillFileDescriptorResponse(
-- const protobuf::FileDescriptor* file_desc, Response* response,
-- std::unordered_set<TString>* seen_files) const;
--
-- template <typename Response>
-- void FillErrorResponse(const Status& status, Response* error_response) const;
--
-- const protobuf::DescriptorPool* descriptor_pool_;
-- const std::vector<string>* services_;
--};
--
- class ProtoServerReflection final
- : public reflection::v1alpha::ServerReflection::Service {
- public:
-- ProtoServerReflection()
-- : grpc::ProtoServerReflection(
-- std::make_shared<ProtoServerReflectionBackend>()) {}
--
-- explicit ProtoServerReflection(
-- std::shared_ptr<ProtoServerReflectionBackend> backend)
-- : backend_(std::move(backend)) {}
-+ ProtoServerReflection();
-
- // Add the full names of registered services
-- void SetServiceList(const std::vector<TString>* services) {
-- backend_->SetServiceList(services);
-- }
-+ void SetServiceList(const std::vector<TString>* services);
-
- // implementation of ServerReflectionInfo(stream ServerReflectionRequest) rpc
- // in ServerReflection service
-@@ -107,26 +50,36 @@ class ProtoServerReflection final
- reflection::v1alpha::ServerReflectionRequest>* stream)
- override;
-
-- std::shared_ptr<ProtoServerReflectionBackend> backend_;
--};
--
--class ProtoServerReflectionV1 final
-- : public reflection::v1::ServerReflection::Service {
-- public:
-- explicit ProtoServerReflectionV1(
-- std::shared_ptr<ProtoServerReflectionBackend> backend)
-- : backend_(std::move(backend)) {}
--
-- // implementation of ServerReflectionInfo(stream ServerReflectionRequest) rpc
-- // in ServerReflection service
-- Status ServerReflectionInfo(
-- ServerContext* /* context */,
-- ServerReaderWriter<reflection::v1::ServerReflectionResponse,
-- reflection::v1::ServerReflectionRequest>* stream)
-- override;
--
- private:
-- std::shared_ptr<ProtoServerReflectionBackend> backend_;
-+ Status ListService(ServerContext* context,
-+ reflection::v1alpha::ListServiceResponse* response);
-+
-+ Status GetFileByName(ServerContext* context, const TString& file_name,
-+ reflection::v1alpha::ServerReflectionResponse* response);
-+
-+ Status GetFileContainingSymbol(
-+ ServerContext* context, const TString& symbol,
-+ reflection::v1alpha::ServerReflectionResponse* response);
-+
-+ Status GetFileContainingExtension(
-+ ServerContext* context,
-+ const reflection::v1alpha::ExtensionRequest* request,
-+ reflection::v1alpha::ServerReflectionResponse* response);
-+
-+ Status GetAllExtensionNumbers(
-+ ServerContext* context, const TString& type,
-+ reflection::v1alpha::ExtensionNumberResponse* response);
-+
-+ void FillFileDescriptorResponse(
-+ const protobuf::FileDescriptor* file_desc,
-+ reflection::v1alpha::ServerReflectionResponse* response,
-+ std::unordered_set<TString>* seen_files);
-+
-+ void FillErrorResponse(const Status& status,
-+ reflection::v1alpha::ErrorResponse* error_response);
-+
-+ const protobuf::DescriptorPool* descriptor_pool_;
-+ const std::vector<string>* services_;
- };
-
- } // namespace grpc
---- contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc (d9e6a4052b262a203f1761906f0927c2cac29938)
-+++ contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc (3f1601dbf9160951f00fa9c173d5878d97719032)
-@@ -16,10 +16,6 @@
- //
- //
-
--#include <memory>
--#include <util/generic/string.h>
--#include <util/string/cast.h>
--
- #include <grpcpp/ext/proto_server_reflection_plugin.h>
- #include <grpcpp/impl/server_builder_plugin.h>
- #include <grpcpp/impl/server_initializer.h>
-@@ -31,40 +27,35 @@ namespace grpc {
- namespace reflection {
-
- ProtoServerReflectionPlugin::ProtoServerReflectionPlugin()
-- : backend_(std::make_shared<ProtoServerReflectionBackend>()),
-- reflection_service_v1alpha_(
-- std::make_shared<ProtoServerReflection>(backend_)),
-- reflection_service_v1_(
-- std::make_shared<ProtoServerReflectionV1>(backend_)) {}
-+ : reflection_service_(new grpc::ProtoServerReflection()) {}
-
- TString ProtoServerReflectionPlugin::name() {
- return "proto_server_reflection";
- }
-
- void ProtoServerReflectionPlugin::InitServer(grpc::ServerInitializer* si) {
-- si->RegisterService(reflection_service_v1_);
-- si->RegisterService(reflection_service_v1alpha_);
-+ si->RegisterService(reflection_service_);
- }
-
- void ProtoServerReflectionPlugin::Finish(grpc::ServerInitializer* si) {
-- backend_->SetServiceList(si->GetServiceList());
-+ reflection_service_->SetServiceList(si->GetServiceList());
- }
-
- void ProtoServerReflectionPlugin::ChangeArguments(const TString& /*name*/,
- void* /*value*/) {}
-
- bool ProtoServerReflectionPlugin::has_sync_methods() const {
-- return (reflection_service_v1_ &&
-- reflection_service_v1_->has_synchronous_methods()) ||
-- (reflection_service_v1alpha_ &&
-- reflection_service_v1alpha_->has_synchronous_methods());
-+ if (reflection_service_) {
-+ return reflection_service_->has_synchronous_methods();
-+ }
-+ return false;
- }
-
- bool ProtoServerReflectionPlugin::has_async_methods() const {
-- return (reflection_service_v1_ &&
-- reflection_service_v1_->has_async_methods()) ||
-- (reflection_service_v1alpha_ &&
-- reflection_service_v1alpha_->has_async_methods());
-+ if (reflection_service_) {
-+ return reflection_service_->has_async_methods();
-+ }
-+ return false;
- }
-
- static std::unique_ptr<grpc::ServerBuilderPlugin> CreateProtoReflection() {
diff --git a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc
index 8fea1c5b680..15867b38398 100644
--- a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc
+++ b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.cc
@@ -23,58 +23,41 @@
#include <grpcpp/grpcpp.h>
#include <grpcpp/support/interceptor.h>
+#include <grpcpp/support/sync_stream.h>
// IWYU pragma: no_include "google/protobuf/descriptor.h"
// IWYU pragma: no_include <google/protobuf/descriptor.h>
-
-using grpc::reflection::v1alpha::ErrorResponse;
-using grpc::reflection::v1alpha::ExtensionNumberResponse;
-using grpc::reflection::v1alpha::ExtensionRequest;
-using grpc::reflection::v1alpha::ListServiceResponse;
-using grpc::reflection::v1alpha::ServerReflectionRequest;
-using grpc::reflection::v1alpha::ServerReflectionResponse;
-using grpc::reflection::v1alpha::ServiceResponse;
+// IWYU pragma: no_include "src/proto/grpc/reflection/v1/reflection.pb.h"
+// IWYU pragma: no_include "src/proto/grpc/reflection/v1alpha/reflection.pb.h"
namespace grpc {
-ProtoServerReflection::ProtoServerReflection()
- : descriptor_pool_(protobuf::DescriptorPool::generated_pool()) {}
-
-void ProtoServerReflection::SetServiceList(
- const std::vector<TString>* services) {
- services_ = services;
-}
-
-Status ProtoServerReflection::ServerReflectionInfo(
- ServerContext* context,
- ServerReaderWriter<ServerReflectionResponse, ServerReflectionRequest>*
- stream) {
- ServerReflectionRequest request;
- ServerReflectionResponse response;
+template <typename Request, typename Response>
+Status ProtoServerReflectionBackend::ServerReflectionInfo(
+ ServerReaderWriter<Response, Request>* stream) const {
+ Request request;
+ Response response;
Status status;
while (stream->Read(&request)) {
switch (request.message_request_case()) {
- case ServerReflectionRequest::MessageRequestCase::kFileByFilename:
- status = GetFileByName(context, request.file_by_filename(), &response);
+ case Request::MessageRequestCase::kFileByFilename:
+ status = GetFileByName(request.file_by_filename(), &response);
break;
- case ServerReflectionRequest::MessageRequestCase::kFileContainingSymbol:
- status = GetFileContainingSymbol(
- context, request.file_containing_symbol(), &response);
+ case Request::MessageRequestCase::kFileContainingSymbol:
+ status = GetFileContainingSymbol(request.file_containing_symbol(),
+ &response);
break;
- case ServerReflectionRequest::MessageRequestCase::
- kFileContainingExtension:
+ case Request::MessageRequestCase::kFileContainingExtension:
status = GetFileContainingExtension(
- context, &request.file_containing_extension(), &response);
+ &request.file_containing_extension(), &response);
break;
- case ServerReflectionRequest::MessageRequestCase::
- kAllExtensionNumbersOfType:
+ case Request::MessageRequestCase::kAllExtensionNumbersOfType:
status = GetAllExtensionNumbers(
- context, request.all_extension_numbers_of_type(),
+ request.all_extension_numbers_of_type(),
response.mutable_all_extension_numbers_response());
break;
- case ServerReflectionRequest::MessageRequestCase::kListServices:
- status =
- ListService(context, response.mutable_list_services_response());
+ case Request::MessageRequestCase::kListServices:
+ status = ListService(response.mutable_list_services_response());
break;
default:
status = Status(StatusCode::UNIMPLEMENTED, "");
@@ -84,41 +67,40 @@ Status ProtoServerReflection::ServerReflectionInfo(
FillErrorResponse(status, response.mutable_error_response());
}
response.set_valid_host(request.host());
- response.set_allocated_original_request(
- new ServerReflectionRequest(request));
+ response.set_allocated_original_request(new Request(request));
stream->Write(response);
}
-
return Status::OK;
}
-void ProtoServerReflection::FillErrorResponse(const Status& status,
- ErrorResponse* error_response) {
+template <typename Response>
+void ProtoServerReflectionBackend::FillErrorResponse(
+ const Status& status, Response* error_response) const {
error_response->set_error_code(status.error_code());
error_response->set_error_message(status.error_message());
}
-Status ProtoServerReflection::ListService(ServerContext* /*context*/,
- ListServiceResponse* response) {
+template <typename Response>
+Status ProtoServerReflectionBackend::ListService(Response* response) const {
if (services_ == nullptr) {
return Status(StatusCode::NOT_FOUND, "Services not found.");
}
for (const auto& value : *services_) {
- ServiceResponse* service_response = response->add_service();
+ auto* service_response = response->add_service();
service_response->set_name(value);
}
return Status::OK;
}
-Status ProtoServerReflection::GetFileByName(
- ServerContext* /*context*/, const TString& file_name,
- ServerReflectionResponse* response) {
+template <typename Response>
+Status ProtoServerReflectionBackend::GetFileByName(const TString& file_name,
+ Response* response) const {
if (descriptor_pool_ == nullptr) {
return Status::CANCELLED;
}
const protobuf::FileDescriptor* file_desc =
- descriptor_pool_->FindFileByName(file_name);
+ descriptor_pool_->FindFileByName(TProtoStringType(file_name));
if (file_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "File not found.");
}
@@ -127,15 +109,15 @@ Status ProtoServerReflection::GetFileByName(
return Status::OK;
}
-Status ProtoServerReflection::GetFileContainingSymbol(
- ServerContext* /*context*/, const TString& symbol,
- ServerReflectionResponse* response) {
+template <typename Response>
+Status ProtoServerReflectionBackend::GetFileContainingSymbol(
+ const TString& symbol, Response* response) const {
if (descriptor_pool_ == nullptr) {
return Status::CANCELLED;
}
const protobuf::FileDescriptor* file_desc =
- descriptor_pool_->FindFileContainingSymbol(symbol);
+ descriptor_pool_->FindFileContainingSymbol(TProtoStringType(symbol));
if (file_desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Symbol not found.");
}
@@ -144,9 +126,9 @@ Status ProtoServerReflection::GetFileContainingSymbol(
return Status::OK;
}
-Status ProtoServerReflection::GetFileContainingExtension(
- ServerContext* /*context*/, const ExtensionRequest* request,
- ServerReflectionResponse* response) {
+template <typename Request, typename Response>
+Status ProtoServerReflectionBackend::GetFileContainingExtension(
+ const Request* request, Response* response) const {
if (descriptor_pool_ == nullptr) {
return Status::CANCELLED;
}
@@ -168,15 +150,15 @@ Status ProtoServerReflection::GetFileContainingExtension(
return Status::OK;
}
-Status ProtoServerReflection::GetAllExtensionNumbers(
- ServerContext* /*context*/, const TString& type,
- ExtensionNumberResponse* response) {
+template <typename Response>
+Status ProtoServerReflectionBackend::GetAllExtensionNumbers(
+ const TString& type, Response* response) const {
if (descriptor_pool_ == nullptr) {
return Status::CANCELLED;
}
const protobuf::Descriptor* desc =
- descriptor_pool_->FindMessageTypeByName(type);
+ descriptor_pool_->FindMessageTypeByName(TProtoStringType(type));
if (desc == nullptr) {
return Status(StatusCode::NOT_FOUND, "Type not found.");
}
@@ -190,17 +172,17 @@ Status ProtoServerReflection::GetAllExtensionNumbers(
return Status::OK;
}
-void ProtoServerReflection::FillFileDescriptorResponse(
- const protobuf::FileDescriptor* file_desc,
- ServerReflectionResponse* response,
- std::unordered_set<TString>* seen_files) {
+template <typename Response>
+void ProtoServerReflectionBackend::FillFileDescriptorResponse(
+ const protobuf::FileDescriptor* file_desc, Response* response,
+ std::unordered_set<TString>* seen_files) const {
if (seen_files->find(file_desc->name()) != seen_files->end()) {
return;
}
seen_files->insert(file_desc->name());
protobuf::FileDescriptorProto file_desc_proto;
- TString data;
+ TProtoStringType data;
file_desc->CopyTo(&file_desc_proto);
file_desc_proto.SerializeToString(&data);
response->mutable_file_descriptor_response()->add_file_descriptor_proto(data);
@@ -210,4 +192,18 @@ void ProtoServerReflection::FillFileDescriptorResponse(
}
}
+Status ProtoServerReflection::ServerReflectionInfo(
+ ServerContext* /* context */,
+ ServerReaderWriter<reflection::v1alpha::ServerReflectionResponse,
+ reflection::v1alpha::ServerReflectionRequest>* stream) {
+ return backend_->ServerReflectionInfo(stream);
+}
+
+Status ProtoServerReflectionV1::ServerReflectionInfo(
+ ServerContext* /* context */,
+ ServerReaderWriter<reflection::v1::ServerReflectionResponse,
+ reflection::v1::ServerReflectionRequest>* stream) {
+ return backend_->ServerReflectionInfo(stream);
+}
+
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h
index a65c174d6d3..0d252c2ca80 100644
--- a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h
+++ b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection.h
@@ -19,8 +19,11 @@
#ifndef GRPC_SRC_CPP_EXT_PROTO_SERVER_REFLECTION_H
#define GRPC_SRC_CPP_EXT_PROTO_SERVER_REFLECTION_H
-#include <string>
+#include <memory>
+#include <util/generic/string.h>
+#include <util/string/cast.h>
#include <unordered_set>
+#include <utility>
#include <vector>
#include <grpcpp/grpcpp.h>
@@ -29,18 +32,72 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/sync_stream.h>
+#include "src/proto/grpc/reflection/v1/reflection.grpc.pb.h"
+#include "src/proto/grpc/reflection/v1/reflection.pb.h"
#include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h"
#include "src/proto/grpc/reflection/v1alpha/reflection.pb.h"
namespace grpc {
+class ProtoServerReflectionBackend {
+ public:
+ ProtoServerReflectionBackend()
+ : descriptor_pool_(protobuf::DescriptorPool::generated_pool()) {}
+
+ void SetServiceList(const std::vector<TString>* services) {
+ services_ = services;
+ }
+
+ template <typename Request, typename Response>
+ Status ServerReflectionInfo(
+ ServerReaderWriter<Response, Request>* stream) const;
+
+ private:
+ template <typename Response>
+ Status ListService(Response* response) const;
+
+ template <typename Response>
+ Status GetFileByName(const TString& file_name, Response* response) const;
+
+ template <typename Response>
+ Status GetFileContainingSymbol(const TString& symbol,
+ Response* response) const;
+
+ template <typename Request, typename Response>
+ Status GetFileContainingExtension(const Request* request,
+ Response* response) const;
+
+ template <typename Response>
+ Status GetAllExtensionNumbers(const TString& type,
+ Response* response) const;
+
+ template <typename Response>
+ void FillFileDescriptorResponse(
+ const protobuf::FileDescriptor* file_desc, Response* response,
+ std::unordered_set<TString>* seen_files) const;
+
+ template <typename Response>
+ void FillErrorResponse(const Status& status, Response* error_response) const;
+
+ const protobuf::DescriptorPool* descriptor_pool_;
+ const std::vector<string>* services_;
+};
+
class ProtoServerReflection final
: public reflection::v1alpha::ServerReflection::Service {
public:
- ProtoServerReflection();
+ ProtoServerReflection()
+ : grpc::ProtoServerReflection(
+ std::make_shared<ProtoServerReflectionBackend>()) {}
+
+ explicit ProtoServerReflection(
+ std::shared_ptr<ProtoServerReflectionBackend> backend)
+ : backend_(std::move(backend)) {}
// Add the full names of registered services
- void SetServiceList(const std::vector<TString>* services);
+ void SetServiceList(const std::vector<TString>* services) {
+ backend_->SetServiceList(services);
+ }
// implementation of ServerReflectionInfo(stream ServerReflectionRequest) rpc
// in ServerReflection service
@@ -50,36 +107,26 @@ class ProtoServerReflection final
reflection::v1alpha::ServerReflectionRequest>* stream)
override;
- private:
- Status ListService(ServerContext* context,
- reflection::v1alpha::ListServiceResponse* response);
-
- Status GetFileByName(ServerContext* context, const TString& file_name,
- reflection::v1alpha::ServerReflectionResponse* response);
-
- Status GetFileContainingSymbol(
- ServerContext* context, const TString& symbol,
- reflection::v1alpha::ServerReflectionResponse* response);
-
- Status GetFileContainingExtension(
- ServerContext* context,
- const reflection::v1alpha::ExtensionRequest* request,
- reflection::v1alpha::ServerReflectionResponse* response);
-
- Status GetAllExtensionNumbers(
- ServerContext* context, const TString& type,
- reflection::v1alpha::ExtensionNumberResponse* response);
+ std::shared_ptr<ProtoServerReflectionBackend> backend_;
+};
- void FillFileDescriptorResponse(
- const protobuf::FileDescriptor* file_desc,
- reflection::v1alpha::ServerReflectionResponse* response,
- std::unordered_set<TString>* seen_files);
+class ProtoServerReflectionV1 final
+ : public reflection::v1::ServerReflection::Service {
+ public:
+ explicit ProtoServerReflectionV1(
+ std::shared_ptr<ProtoServerReflectionBackend> backend)
+ : backend_(std::move(backend)) {}
- void FillErrorResponse(const Status& status,
- reflection::v1alpha::ErrorResponse* error_response);
+ // implementation of ServerReflectionInfo(stream ServerReflectionRequest) rpc
+ // in ServerReflection service
+ Status ServerReflectionInfo(
+ ServerContext* /* context */,
+ ServerReaderWriter<reflection::v1::ServerReflectionResponse,
+ reflection::v1::ServerReflectionRequest>* stream)
+ override;
- const protobuf::DescriptorPool* descriptor_pool_;
- const std::vector<string>* services_;
+ private:
+ std::shared_ptr<ProtoServerReflectionBackend> backend_;
};
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc
index 08c30186a95..c55705ee1c6 100644
--- a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc
+++ b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc
@@ -16,6 +16,10 @@
//
//
+#include <memory>
+#include <util/generic/string.h>
+#include <util/string/cast.h>
+
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/impl/server_initializer.h>
@@ -27,35 +31,40 @@ namespace grpc {
namespace reflection {
ProtoServerReflectionPlugin::ProtoServerReflectionPlugin()
- : reflection_service_(new grpc::ProtoServerReflection()) {}
+ : backend_(std::make_shared<ProtoServerReflectionBackend>()),
+ reflection_service_v1alpha_(
+ std::make_shared<ProtoServerReflection>(backend_)),
+ reflection_service_v1_(
+ std::make_shared<ProtoServerReflectionV1>(backend_)) {}
TString ProtoServerReflectionPlugin::name() {
return "proto_server_reflection";
}
void ProtoServerReflectionPlugin::InitServer(grpc::ServerInitializer* si) {
- si->RegisterService(reflection_service_);
+ si->RegisterService(reflection_service_v1_);
+ si->RegisterService(reflection_service_v1alpha_);
}
void ProtoServerReflectionPlugin::Finish(grpc::ServerInitializer* si) {
- reflection_service_->SetServiceList(si->GetServiceList());
+ backend_->SetServiceList(si->GetServiceList());
}
void ProtoServerReflectionPlugin::ChangeArguments(const TString& /*name*/,
void* /*value*/) {}
bool ProtoServerReflectionPlugin::has_sync_methods() const {
- if (reflection_service_) {
- return reflection_service_->has_synchronous_methods();
- }
- return false;
+ return (reflection_service_v1_ &&
+ reflection_service_v1_->has_synchronous_methods()) ||
+ (reflection_service_v1alpha_ &&
+ reflection_service_v1alpha_->has_synchronous_methods());
}
bool ProtoServerReflectionPlugin::has_async_methods() const {
- if (reflection_service_) {
- return reflection_service_->has_async_methods();
- }
- return false;
+ return (reflection_service_v1_ &&
+ reflection_service_v1_->has_async_methods()) ||
+ (reflection_service_v1alpha_ &&
+ reflection_service_v1alpha_->has_async_methods());
}
static std::unique_ptr<grpc::ServerBuilderPlugin> CreateProtoReflection() {