proto_reflection_descriptor_database.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 #ifndef GRPC_TEST_CPP_PROTO_SERVER_REFLECTION_DATABSE_H
19 #define GRPC_TEST_CPP_PROTO_SERVER_REFLECTION_DATABSE_H
20 
21 #include <mutex>
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <vector>
25 
26 #include <grpcpp/grpcpp.h>
28 
29 #include "src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h"
30 
31 namespace grpc {
32 
33 // ProtoReflectionDescriptorDatabase takes a stub of ServerReflection and
34 // provides the methods defined by DescriptorDatabase interfaces. It can be used
35 // to feed a DescriptorPool instance.
37  public:
39  std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub);
40 
42  const std::shared_ptr<grpc::Channel>& channel);
43 
45 
46  // The following four methods implement DescriptorDatabase interfaces.
47  //
48  // Find a file by file name. Fills in *output and returns true if found.
49  // Otherwise, returns false, leaving the contents of *output undefined.
50  bool FindFileByName(const string& filename,
52 
53  // Find the file that declares the given fully-qualified symbol name.
54  // If found, fills in *output and returns true, otherwise returns false
55  // and leaves *output undefined.
56  bool FindFileContainingSymbol(const string& symbol_name,
58 
59  // Find the file which defines an extension extending the given message type
60  // with the given field number. If found, fills in *output and returns true,
61  // otherwise returns false and leaves *output undefined. containing_type
62  // must be a fully-qualified type name.
64  const string& containing_type, int field_number,
66 
67  // Finds the tag numbers used by all known extensions of
68  // extendee_type, and appends them to output in an undefined
69  // order. This method is best-effort: it's not guaranteed that the
70  // database will find all extensions, and it's not guaranteed that
71  // FindFileContainingExtension will return true on all of the found
72  // numbers. Returns true if the search was successful, otherwise
73  // returns false and leaves output unchanged.
74  bool FindAllExtensionNumbers(const string& extendee_type,
75  std::vector<int>* output) override;
76 
77  // Provide a list of full names of registered services
78  bool GetServices(std::vector<std::string>* output);
79 
80  private:
81  typedef ClientReaderWriter<
82  grpc::reflection::v1alpha::ServerReflectionRequest,
83  grpc::reflection::v1alpha::ServerReflectionResponse>
85 
87  const std::string& byte_fd_proto);
88 
90  const grpc::reflection::v1alpha::FileDescriptorResponse& response);
91 
92  std::shared_ptr<ClientStream> GetStream();
93 
94  bool DoOneRequest(
95  const grpc::reflection::v1alpha::ServerReflectionRequest& request,
96  grpc::reflection::v1alpha::ServerReflectionResponse& response);
97 
98  std::shared_ptr<ClientStream> stream_;
100  std::unique_ptr<grpc::reflection::v1alpha::ServerReflection::Stub> stub_;
101  std::unordered_set<string> known_files_;
102  std::unordered_set<string> missing_symbols_;
103  std::unordered_map<string, std::unordered_set<int>> missing_extensions_;
104  std::unordered_map<string, std::vector<int>> cached_extension_numbers_;
106 
108 };
109 
110 } // namespace grpc
111 
112 #endif // GRPC_TEST_CPP_METRICS_SERVER_H
grpc::ProtoReflectionDescriptorDatabase
Definition: proto_reflection_descriptor_database.h:36
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
grpc::ProtoReflectionDescriptorDatabase::FindFileContainingExtension
bool FindFileContainingExtension(const string &containing_type, int field_number, protobuf::FileDescriptorProto *output) override
Definition: proto_reflection_descriptor_database.cc:157
grpc::ProtoReflectionDescriptorDatabase::stub_
std::unique_ptr< grpc::reflection::v1alpha::ServerReflection::Stub > stub_
Definition: proto_reflection_descriptor_database.h:100
grpc
Definition: grpcpp/alarm.h:33
mutex
static uv_mutex_t mutex
Definition: threadpool.c:34
grpc::ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase
~ProtoReflectionDescriptorDatabase() override
Definition: proto_reflection_descriptor_database.cc:41
benchmark.request
request
Definition: benchmark.py:77
grpc::ProtoReflectionDescriptorDatabase::ClientStream
ClientReaderWriter< grpc::reflection::v1alpha::ServerReflectionRequest, grpc::reflection::v1alpha::ServerReflectionResponse > ClientStream
Definition: proto_reflection_descriptor_database.h:84
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase
ProtoReflectionDescriptorDatabase(std::unique_ptr< reflection::v1alpha::ServerReflection::Stub > stub)
async_greeter_client.stub
stub
Definition: hellostreamingworld/async_greeter_client.py:26
grpc::ProtoReflectionDescriptorDatabase::stream_mutex_
std::mutex stream_mutex_
Definition: proto_reflection_descriptor_database.h:105
grpc::ProtoReflectionDescriptorDatabase::DoOneRequest
bool DoOneRequest(const grpc::reflection::v1alpha::ServerReflectionRequest &request, grpc::reflection::v1alpha::ServerReflectionResponse &response)
Definition: proto_reflection_descriptor_database.cc:321
grpc::ClientReaderWriter
Definition: grpcpp/impl/codegen/channel_interface.h:35
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
grpc::ProtoReflectionDescriptorDatabase::missing_extensions_
std::unordered_map< string, std::unordered_set< int > > missing_extensions_
Definition: proto_reflection_descriptor_database.h:103
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
grpc::ProtoReflectionDescriptorDatabase::stream_
std::shared_ptr< ClientStream > stream_
Definition: proto_reflection_descriptor_database.h:98
grpc::ProtoReflectionDescriptorDatabase::FindFileContainingSymbol
bool FindFileContainingSymbol(const string &symbol_name, protobuf::FileDescriptorProto *output) override
Definition: proto_reflection_descriptor_database.cc:109
grpcpp.h
phone_pb2.containing_type
containing_type
Definition: phone_pb2.py:199
google::protobuf::DescriptorDatabase
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:71
grpc::ClientContext
Definition: grpcpp/impl/codegen/client_context.h:195
grpc::ProtoReflectionDescriptorDatabase::AddFileFromResponse
void AddFileFromResponse(const grpc::reflection::v1alpha::FileDescriptorResponse &response)
Definition: proto_reflection_descriptor_database.cc:301
grpc::ProtoReflectionDescriptorDatabase::ctx_
grpc::ClientContext ctx_
Definition: proto_reflection_descriptor_database.h:99
grpc::ProtoReflectionDescriptorDatabase::cached_extension_numbers_
std::unordered_map< string, std::vector< int > > cached_extension_numbers_
Definition: proto_reflection_descriptor_database.h:104
grpc::ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers
bool FindAllExtensionNumbers(const string &extendee_type, std::vector< int > *output) override
Definition: proto_reflection_descriptor_database.cc:219
config_protobuf.h
grpc::ProtoReflectionDescriptorDatabase::GetServices
bool GetServices(std::vector< std::string > *output)
Definition: proto_reflection_descriptor_database.cc:259
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
grpc::ProtoReflectionDescriptorDatabase::known_files_
std::unordered_set< string > known_files_
Definition: proto_reflection_descriptor_database.h:101
grpc::protobuf::FileDescriptorProto
GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto
Definition: include/grpcpp/impl/codegen/config_protobuf.h:86
grpc::ProtoReflectionDescriptorDatabase::ParseFileDescriptorProtoResponse
protobuf::FileDescriptorProto ParseFileDescriptorProtoResponse(const std::string &byte_fd_proto)
Definition: proto_reflection_descriptor_database.cc:294
google::protobuf::SimpleDescriptorDatabase
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:162
grpc::ProtoReflectionDescriptorDatabase::missing_symbols_
std::unordered_set< string > missing_symbols_
Definition: proto_reflection_descriptor_database.h:102
grpc::ProtoReflectionDescriptorDatabase::cached_db_
protobuf::SimpleDescriptorDatabase cached_db_
Definition: proto_reflection_descriptor_database.h:107
grpc::ProtoReflectionDescriptorDatabase::GetStream
std::shared_ptr< ClientStream > GetStream()
Definition: proto_reflection_descriptor_database.cc:314
grpc::ProtoReflectionDescriptorDatabase::FindFileByName
bool FindFileByName(const string &filename, protobuf::FileDescriptorProto *output) override
Definition: proto_reflection_descriptor_database.cc:62


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:56