diff options
author | Yuchen Zeng <zyc@google.com> | 2016-05-19 15:10:22 -0700 |
---|---|---|
committer | Yuchen Zeng <zyc@google.com> | 2016-05-19 15:10:22 -0700 |
commit | ace4986e653e51e1e7dcab0beabdfa460e0a61c8 (patch) | |
tree | 45f8a6f7a7f75eb4891a9a54247e9d1345615306 /extensions | |
parent | 749005efcc657cc5199c67688b734fb3de5852fe (diff) |
Update reflection implementation along with API changes
Diffstat (limited to 'extensions')
4 files changed, 25 insertions, 15 deletions
diff --git a/extensions/include/grpc++/impl/proto_server_reflection_plugin.h b/extensions/include/grpc++/impl/proto_server_reflection_plugin.h index adc6eb7bc3..e09c413251 100644 --- a/extensions/include/grpc++/impl/proto_server_reflection_plugin.h +++ b/extensions/include/grpc++/impl/proto_server_reflection_plugin.h @@ -61,13 +61,22 @@ class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin { std::shared_ptr<::grpc::ProtoServerReflection> reflection_service; }; -std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { - return std::unique_ptr<::grpc::ServerBuilderPlugin>( - new ProtoServerReflectionPlugin()); -} +// std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { +// return std::unique_ptr<::grpc::ServerBuilderPlugin>( +// new ProtoServerReflectionPlugin()); +// } + +std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection(); void grpc_AddServerBuilderPlugin_reflection(); +// Force AddServerBuilderPlugin() to be called at static initialization time. +struct StaticPluginInitializer_reflection { + StaticPluginInitializer_reflection() { + grpc_AddServerBuilderPlugin_reflection(); + } +} static_plugin_initializer_reflection_; + } // namespace reflection } // namespace grpc diff --git a/extensions/reflection/proto_server_reflection.cc b/extensions/reflection/proto_server_reflection.cc index ec82d5f18e..28292a42d6 100644 --- a/extensions/reflection/proto_server_reflection.cc +++ b/extensions/reflection/proto_server_reflection.cc @@ -105,6 +105,9 @@ Status ProtoServerReflection::ServerReflectionInfo( status = Status(StatusCode::UNIMPLEMENTED, ""); } + if (!status.ok()) { + FillErrorResponse(status, response.mutable_error_response()); + } response.set_valid_host(request.host()); response.set_allocated_original_request( new ServerReflectionRequest(request)); @@ -114,10 +117,10 @@ Status ProtoServerReflection::ServerReflectionInfo( return Status::OK; } -void ProtoServerReflection::FillErrorResponse(Status* status, +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()); + error_response->set_error_code(status.error_code()); + error_response->set_error_message(status.error_message()); } Status ProtoServerReflection::ListService(ServerContext* context, diff --git a/extensions/reflection/proto_server_reflection.h b/extensions/reflection/proto_server_reflection.h index f86d6f1bf4..53deef906c 100644 --- a/extensions/reflection/proto_server_reflection.h +++ b/extensions/reflection/proto_server_reflection.h @@ -85,7 +85,7 @@ class ProtoServerReflection GRPC_FINAL const google::protobuf::FileDescriptor* file_desc, reflection::v1alpha::ServerReflectionResponse* response); - void FillErrorResponse(Status* status, + void FillErrorResponse(const Status& status, reflection::v1alpha::ErrorResponse* error_response); const google::protobuf::DescriptorPool* descriptor_pool_; diff --git a/extensions/reflection/proto_server_reflection_plugin.cc b/extensions/reflection/proto_server_reflection_plugin.cc index 6adfa45047..d038a7fff5 100644 --- a/extensions/reflection/proto_server_reflection_plugin.cc +++ b/extensions/reflection/proto_server_reflection_plugin.cc @@ -71,6 +71,11 @@ bool ProtoServerReflectionPlugin::has_async_methods() const { return false; } +std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { + return std::unique_ptr<::grpc::ServerBuilderPlugin>( + new ProtoServerReflectionPlugin()); +} + void grpc_AddServerBuilderPlugin_reflection() { static bool already_here = false; if (already_here) return; @@ -78,12 +83,5 @@ void grpc_AddServerBuilderPlugin_reflection() { ::grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection); } -// Force AddServerBuilderPlugin() to be called at static initialization time. -struct StaticPluginInitializer_reflection { - StaticPluginInitializer_reflection() { - grpc_AddServerBuilderPlugin_reflection(); - } -} static_plugin_initializer_reflection_; - } // namespace reflection } // namespace grpc |