Addressed reveiw comments about naming

pull/6438/head
Yuchen Zeng 9 years ago
parent c8074527b2
commit 1495cb5b24
  1. 11
      extensions/include/grpc++/impl/proto_server_reflection_plugin.h
  2. 10
      extensions/reflection/proto_server_reflection_plugin.cc
  3. 1
      test/cpp/end2end/proto_server_reflection_test.cc
  4. 34
      test/cpp/util/proto_reflection_descriptor_database.cc
  5. 4
      test/cpp/util/proto_reflection_descriptor_database.h
  6. 3
      tools/dockerfile/grpc_check_generated_pb_files/check_pb_files.sh

@ -59,17 +59,6 @@ class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin {
std::shared_ptr<::grpc::ProtoServerReflection> reflection_service_; std::shared_ptr<::grpc::ProtoServerReflection> reflection_service_;
}; };
std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection();
void grpc_AddServerBuilderPlugin_reflection();
// Force AddServerBuilderPlugin() to be called at static initialization time.
static struct StaticPluginInitializer_reflection {
StaticPluginInitializer_reflection() {
grpc_AddServerBuilderPlugin_reflection();
}
} static_plugin_initializer_reflection;
} // namespace reflection } // namespace reflection
} // namespace grpc } // namespace grpc

@ -73,17 +73,23 @@ bool ProtoServerReflectionPlugin::has_async_methods() const {
return false; return false;
} }
std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { static std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() {
return std::unique_ptr<::grpc::ServerBuilderPlugin>( return std::unique_ptr<::grpc::ServerBuilderPlugin>(
new ProtoServerReflectionPlugin()); new ProtoServerReflectionPlugin());
} }
void grpc_AddServerBuilderPlugin_reflection() { static void AddProtoReflectionServerBuilderPlugin() {
static bool already_here = false; static bool already_here = false;
if (already_here) return; if (already_here) return;
already_here = true; already_here = true;
::grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection); ::grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection);
} }
struct StaticProtoReflectionPluginInitializer {
StaticProtoReflectionPluginInitializer() {
AddProtoReflectionServerBuilderPlugin();
}
} static_proto_reflection_plugin_initializer;
} // namespace reflection } // namespace reflection
} // namespace grpc } // namespace grpc

@ -140,6 +140,7 @@ class ProtoServerReflectionTest : public ::testing::Test {
std::unordered_set<string> known_types_; std::unordered_set<string> known_types_;
const google::protobuf::DescriptorPool* ref_desc_pool_; const google::protobuf::DescriptorPool* ref_desc_pool_;
int port_; int port_;
reflection::ProtoServerReflectionPlugin plugin_;
}; };
TEST_F(ProtoServerReflectionTest, CheckResponseWithLocalDescriptorPool) { TEST_F(ProtoServerReflectionTest, CheckResponseWithLocalDescriptorPool) {

@ -69,10 +69,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName(
request.set_file_by_filename(filename); request.set_file_by_filename(filename);
ServerReflectionResponse response; ServerReflectionResponse response;
stream_mutex_.lock(); DoOneRequest(request, response);
GetStream()->Write(request);
GetStream()->Read(&response);
stream_mutex_.unlock();
if (response.message_response_case() == if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) {
@ -117,10 +114,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol(
request.set_file_containing_symbol(symbol_name); request.set_file_containing_symbol(symbol_name);
ServerReflectionResponse response; ServerReflectionResponse response;
stream_mutex_.lock(); DoOneRequest(request, response);
GetStream()->Write(request);
GetStream()->Read(&response);
stream_mutex_.unlock();
if (response.message_response_case() == if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) {
@ -174,10 +168,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
field_number); field_number);
ServerReflectionResponse response; ServerReflectionResponse response;
stream_mutex_.lock(); DoOneRequest(request, response);
GetStream()->Write(request);
GetStream()->Read(&response);
stream_mutex_.unlock();
if (response.message_response_case() == if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) {
@ -227,10 +218,7 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
request.set_all_extension_numbers_of_type(extendee_type); request.set_all_extension_numbers_of_type(extendee_type);
ServerReflectionResponse response; ServerReflectionResponse response;
stream_mutex_.lock(); DoOneRequest(request, response);
GetStream()->Write(request);
GetStream()->Read(&response);
stream_mutex_.unlock();
if (response.message_response_case() == if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase:: ServerReflectionResponse::MessageResponseCase::
@ -262,10 +250,7 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
request.set_list_services(""); request.set_list_services("");
ServerReflectionResponse response; ServerReflectionResponse response;
stream_mutex_.lock(); DoOneRequest(request, response);
GetStream()->Write(request);
GetStream()->Read(&response);
stream_mutex_.unlock();
if (response.message_response_case() == if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kListServicesResponse) { ServerReflectionResponse::MessageResponseCase::kListServicesResponse) {
@ -319,4 +304,13 @@ ProtoReflectionDescriptorDatabase::GetStream() {
return stream_; return stream_;
} }
void ProtoReflectionDescriptorDatabase::DoOneRequest(
const ServerReflectionRequest& request,
ServerReflectionResponse& response) {
stream_mutex_.lock();
GetStream()->Write(request);
GetStream()->Read(&response);
stream_mutex_.unlock();
}
} // namespace grpc } // namespace grpc

@ -91,6 +91,10 @@ class ProtoReflectionDescriptorDatabase
const std::shared_ptr<ClientStream> GetStream(); const std::shared_ptr<ClientStream> GetStream();
void DoOneRequest(
const grpc::reflection::v1alpha::ServerReflectionRequest& request,
grpc::reflection::v1alpha::ServerReflectionResponse& response);
std::shared_ptr<ClientStream> stream_; std::shared_ptr<ClientStream> stream_;
grpc::ClientContext ctx_; grpc::ClientContext ctx_;
std::unique_ptr<grpc::reflection::v1alpha::ServerReflection::Stub> stub_; std::unique_ptr<grpc::reflection::v1alpha::ServerReflection::Stub> stub_;

@ -33,9 +33,6 @@ set -e
mkdir -p /var/local/git mkdir -p /var/local/git
git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
# copy service account keys if available
cp -r /var/local/jenkins/service_account $HOME || true
cd /var/local/git/grpc cd /var/local/git/grpc
# build grpc cpp plugin for generating grpc pb files # build grpc cpp plugin for generating grpc pb files

Loading…
Cancel
Save