mirror of https://github.com/grpc/grpc.git
parent
099b756269
commit
c84ed6813e
25 changed files with 6309 additions and 8 deletions
@ -0,0 +1,74 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPCXX_PROTO_SERVER_REFLECTION_PLUGIN_H |
||||
#define GRPCXX_PROTO_SERVER_REFLECTION_PLUGIN_H |
||||
|
||||
#include <memory> |
||||
|
||||
#include <grpc++/impl/server_builder_plugin.h> |
||||
#include <grpc++/support/config.h> |
||||
|
||||
namespace grpc { |
||||
class ServerInitializer; |
||||
class ProtoServerReflection; |
||||
} // namespace grpc
|
||||
|
||||
namespace grpc { |
||||
namespace reflection { |
||||
|
||||
class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin { |
||||
public: |
||||
ProtoServerReflectionPlugin(); |
||||
::grpc::string name() GRPC_OVERRIDE; |
||||
void InitServer(::grpc::ServerInitializer* si) GRPC_OVERRIDE; |
||||
void Finish(::grpc::ServerInitializer* si) GRPC_OVERRIDE; |
||||
void ChangeArguments(const ::grpc::string& name, void* value) GRPC_OVERRIDE; |
||||
bool has_async_methods() const GRPC_OVERRIDE; |
||||
bool has_sync_methods() const GRPC_OVERRIDE; |
||||
|
||||
private: |
||||
std::shared_ptr<::grpc::ProtoServerReflection> reflection_service; |
||||
}; |
||||
|
||||
std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { |
||||
return std::unique_ptr<::grpc::ServerBuilderPlugin>( |
||||
new ProtoServerReflectionPlugin()); |
||||
} |
||||
|
||||
void grpc_AddServerBuilderPlugin_reflection(); |
||||
|
||||
} // namespace reflection
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_PROTO_SERVER_REFLECTION_PLUGIN_H
|
@ -0,0 +1,555 @@ |
||||
// Generated by the gRPC protobuf plugin.
|
||||
// If you make any local change, they will be lost.
|
||||
// source: reflection.proto
|
||||
#ifndef GRPC_reflection_2eproto__INCLUDED |
||||
#define GRPC_reflection_2eproto__INCLUDED |
||||
|
||||
#include <grpc++/impl/reflection.pb.h> |
||||
|
||||
#include <grpc++/impl/codegen/async_stream.h> |
||||
#include <grpc++/impl/codegen/async_unary_call.h> |
||||
#include <grpc++/impl/codegen/proto_utils.h> |
||||
#include <grpc++/impl/codegen/rpc_method.h> |
||||
#include <grpc++/impl/codegen/service_type.h> |
||||
#include <grpc++/impl/codegen/status.h> |
||||
#include <grpc++/impl/codegen/stub_options.h> |
||||
#include <grpc++/impl/codegen/sync_stream.h> |
||||
|
||||
namespace grpc { |
||||
class CompletionQueue; |
||||
class Channel; |
||||
class RpcService; |
||||
class ServerCompletionQueue; |
||||
class ServerContext; |
||||
} // namespace grpc
|
||||
|
||||
namespace grpc { |
||||
namespace reflection { |
||||
namespace v1alpha { |
||||
|
||||
class ServerReflection GRPC_FINAL { |
||||
public: |
||||
class StubInterface { |
||||
public: |
||||
virtual ~StubInterface() {} |
||||
virtual ::grpc::Status ListService( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response) = 0; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>> |
||||
AsyncListService(::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>>( |
||||
AsyncListServiceRaw(context, request, cq)); |
||||
} |
||||
virtual ::grpc::Status GetFileByName( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) = 0; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>> |
||||
AsyncGetFileByName( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>>( |
||||
AsyncGetFileByNameRaw(context, request, cq)); |
||||
} |
||||
virtual ::grpc::Status GetFileContainingSymbol( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) = 0; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>> |
||||
AsyncGetFileContainingSymbol( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>>( |
||||
AsyncGetFileContainingSymbolRaw(context, request, cq)); |
||||
} |
||||
virtual ::grpc::Status GetFileContainingExtension( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) = 0; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>> |
||||
AsyncGetFileContainingExtension( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>>( |
||||
AsyncGetFileContainingExtensionRaw(context, request, cq)); |
||||
} |
||||
virtual ::grpc::Status GetAllExtensionNumbers( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response) = 0; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>> |
||||
AsyncGetAllExtensionNumbers( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>>( |
||||
AsyncGetAllExtensionNumbersRaw(context, request, cq)); |
||||
} |
||||
|
||||
private: |
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>* |
||||
AsyncListServiceRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::CompletionQueue* cq) = 0; |
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
AsyncGetFileByNameRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::CompletionQueue* cq) = 0; |
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
AsyncGetFileContainingSymbolRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::CompletionQueue* cq) = 0; |
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
AsyncGetFileContainingExtensionRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::CompletionQueue* cq) = 0; |
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>* |
||||
AsyncGetAllExtensionNumbersRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::CompletionQueue* cq) = 0; |
||||
}; |
||||
class Stub GRPC_FINAL : public StubInterface { |
||||
public: |
||||
Stub(const std::shared_ptr<::grpc::ChannelInterface>& channel); |
||||
::grpc::Status ListService( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response) |
||||
GRPC_OVERRIDE; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>> |
||||
AsyncListService(::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>>( |
||||
AsyncListServiceRaw(context, request, cq)); |
||||
} |
||||
::grpc::Status GetFileByName( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_OVERRIDE; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>> |
||||
AsyncGetFileByName( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>>( |
||||
AsyncGetFileByNameRaw(context, request, cq)); |
||||
} |
||||
::grpc::Status GetFileContainingSymbol( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_OVERRIDE; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>> |
||||
AsyncGetFileContainingSymbol( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>>( |
||||
AsyncGetFileContainingSymbolRaw(context, request, cq)); |
||||
} |
||||
::grpc::Status GetFileContainingExtension( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_OVERRIDE; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>> |
||||
AsyncGetFileContainingExtension( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>>( |
||||
AsyncGetFileContainingExtensionRaw(context, request, cq)); |
||||
} |
||||
::grpc::Status GetAllExtensionNumbers( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response) |
||||
GRPC_OVERRIDE; |
||||
std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>> |
||||
AsyncGetAllExtensionNumbers( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return std::unique_ptr<::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>>( |
||||
AsyncGetAllExtensionNumbersRaw(context, request, cq)); |
||||
} |
||||
|
||||
private: |
||||
std::shared_ptr<::grpc::ChannelInterface> channel_; |
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>* |
||||
AsyncListServiceRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::CompletionQueue* cq) GRPC_OVERRIDE; |
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
AsyncGetFileByNameRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::CompletionQueue* cq) GRPC_OVERRIDE; |
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
AsyncGetFileContainingSymbolRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::CompletionQueue* cq) GRPC_OVERRIDE; |
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
AsyncGetFileContainingExtensionRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::CompletionQueue* cq) GRPC_OVERRIDE; |
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>* |
||||
AsyncGetAllExtensionNumbersRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::CompletionQueue* cq) GRPC_OVERRIDE; |
||||
const ::grpc::RpcMethod rpcmethod_ListService_; |
||||
const ::grpc::RpcMethod rpcmethod_GetFileByName_; |
||||
const ::grpc::RpcMethod rpcmethod_GetFileContainingSymbol_; |
||||
const ::grpc::RpcMethod rpcmethod_GetFileContainingExtension_; |
||||
const ::grpc::RpcMethod rpcmethod_GetAllExtensionNumbers_; |
||||
}; |
||||
static std::unique_ptr<Stub> NewStub( |
||||
const std::shared_ptr<::grpc::ChannelInterface>& channel, |
||||
const ::grpc::StubOptions& options = ::grpc::StubOptions()); |
||||
|
||||
class Service : public ::grpc::Service { |
||||
public: |
||||
Service(); |
||||
virtual ~Service(); |
||||
virtual ::grpc::Status ListService( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest* request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response); |
||||
virtual ::grpc::Status GetFileByName( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response); |
||||
virtual ::grpc::Status GetFileContainingSymbol( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response); |
||||
virtual ::grpc::Status GetFileContainingExtension( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response); |
||||
virtual ::grpc::Status GetAllExtensionNumbers( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest* request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response); |
||||
}; |
||||
template <class BaseClass> |
||||
class WithAsyncMethod_ListService : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithAsyncMethod_ListService() { ::grpc::Service::MarkMethodAsync(0); } |
||||
~WithAsyncMethod_ListService() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status ListService( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest* request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
void RequestListService( |
||||
::grpc::ServerContext* context, |
||||
::grpc::reflection::v1alpha::EmptyRequest* request, |
||||
::grpc::ServerAsyncResponseWriter< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>* response, |
||||
::grpc::CompletionQueue* new_call_cq, |
||||
::grpc::ServerCompletionQueue* notification_cq, void* tag) { |
||||
::grpc::Service::RequestAsyncUnary(0, context, request, response, |
||||
new_call_cq, notification_cq, tag); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithAsyncMethod_GetFileByName : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithAsyncMethod_GetFileByName() { ::grpc::Service::MarkMethodAsync(1); } |
||||
~WithAsyncMethod_GetFileByName() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetFileByName( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
void RequestGetFileByName( |
||||
::grpc::ServerContext* context, |
||||
::grpc::reflection::v1alpha::FileNameRequest* request, |
||||
::grpc::ServerAsyncResponseWriter< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* response, |
||||
::grpc::CompletionQueue* new_call_cq, |
||||
::grpc::ServerCompletionQueue* notification_cq, void* tag) { |
||||
::grpc::Service::RequestAsyncUnary(1, context, request, response, |
||||
new_call_cq, notification_cq, tag); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithAsyncMethod_GetFileContainingSymbol : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithAsyncMethod_GetFileContainingSymbol() { |
||||
::grpc::Service::MarkMethodAsync(2); |
||||
} |
||||
~WithAsyncMethod_GetFileContainingSymbol() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetFileContainingSymbol( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
void RequestGetFileContainingSymbol( |
||||
::grpc::ServerContext* context, |
||||
::grpc::reflection::v1alpha::SymbolRequest* request, |
||||
::grpc::ServerAsyncResponseWriter< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* response, |
||||
::grpc::CompletionQueue* new_call_cq, |
||||
::grpc::ServerCompletionQueue* notification_cq, void* tag) { |
||||
::grpc::Service::RequestAsyncUnary(2, context, request, response, |
||||
new_call_cq, notification_cq, tag); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithAsyncMethod_GetFileContainingExtension : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithAsyncMethod_GetFileContainingExtension() { |
||||
::grpc::Service::MarkMethodAsync(3); |
||||
} |
||||
~WithAsyncMethod_GetFileContainingExtension() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetFileContainingExtension( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
void RequestGetFileContainingExtension( |
||||
::grpc::ServerContext* context, |
||||
::grpc::reflection::v1alpha::ExtensionRequest* request, |
||||
::grpc::ServerAsyncResponseWriter< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* response, |
||||
::grpc::CompletionQueue* new_call_cq, |
||||
::grpc::ServerCompletionQueue* notification_cq, void* tag) { |
||||
::grpc::Service::RequestAsyncUnary(3, context, request, response, |
||||
new_call_cq, notification_cq, tag); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithAsyncMethod_GetAllExtensionNumbers : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithAsyncMethod_GetAllExtensionNumbers() { |
||||
::grpc::Service::MarkMethodAsync(4); |
||||
} |
||||
~WithAsyncMethod_GetAllExtensionNumbers() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetAllExtensionNumbers( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest* request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
void RequestGetAllExtensionNumbers( |
||||
::grpc::ServerContext* context, |
||||
::grpc::reflection::v1alpha::TypeRequest* request, |
||||
::grpc::ServerAsyncResponseWriter< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>* response, |
||||
::grpc::CompletionQueue* new_call_cq, |
||||
::grpc::ServerCompletionQueue* notification_cq, void* tag) { |
||||
::grpc::Service::RequestAsyncUnary(4, context, request, response, |
||||
new_call_cq, notification_cq, tag); |
||||
} |
||||
}; |
||||
typedef WithAsyncMethod_ListService< |
||||
WithAsyncMethod_GetFileByName<WithAsyncMethod_GetFileContainingSymbol< |
||||
WithAsyncMethod_GetFileContainingExtension< |
||||
WithAsyncMethod_GetAllExtensionNumbers<Service>>>>> |
||||
AsyncService; |
||||
template <class BaseClass> |
||||
class WithGenericMethod_ListService : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithGenericMethod_ListService() { ::grpc::Service::MarkMethodGeneric(0); } |
||||
~WithGenericMethod_ListService() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status ListService( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest* request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithGenericMethod_GetFileByName : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithGenericMethod_GetFileByName() { ::grpc::Service::MarkMethodGeneric(1); } |
||||
~WithGenericMethod_GetFileByName() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetFileByName( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithGenericMethod_GetFileContainingSymbol : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithGenericMethod_GetFileContainingSymbol() { |
||||
::grpc::Service::MarkMethodGeneric(2); |
||||
} |
||||
~WithGenericMethod_GetFileContainingSymbol() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetFileContainingSymbol( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithGenericMethod_GetFileContainingExtension : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithGenericMethod_GetFileContainingExtension() { |
||||
::grpc::Service::MarkMethodGeneric(3); |
||||
} |
||||
~WithGenericMethod_GetFileContainingExtension() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetFileContainingExtension( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
}; |
||||
template <class BaseClass> |
||||
class WithGenericMethod_GetAllExtensionNumbers : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(Service* service) {} |
||||
|
||||
public: |
||||
WithGenericMethod_GetAllExtensionNumbers() { |
||||
::grpc::Service::MarkMethodGeneric(4); |
||||
} |
||||
~WithGenericMethod_GetAllExtensionNumbers() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status GetAllExtensionNumbers( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest* request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response) |
||||
GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
}; |
||||
}; |
||||
|
||||
} // namespace v1alpha
|
||||
} // namespace reflection
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPC_reflection_2eproto__INCLUDED
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,172 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <iostream> |
||||
#include <memory> |
||||
#include <string> |
||||
#include <vector> |
||||
|
||||
#include <google/protobuf/descriptor.h> |
||||
#include <google/protobuf/descriptor.pb.h> |
||||
#include <grpc++/grpc++.h> |
||||
|
||||
#include "reflection/proto_server_reflection.h" |
||||
|
||||
using grpc::Status; |
||||
using grpc::StatusCode; |
||||
using google::protobuf::MethodDescriptor; |
||||
using google::protobuf::ServiceDescriptor; |
||||
using google::protobuf::Descriptor; |
||||
using google::protobuf::FileDescriptor; |
||||
using google::protobuf::FieldDescriptor; |
||||
using google::protobuf::DescriptorPool; |
||||
using google::protobuf::FileDescriptorProto; |
||||
using grpc::reflection::v1alpha::EmptyRequest; |
||||
using grpc::reflection::v1alpha::ListServiceResponse; |
||||
using grpc::reflection::v1alpha::FileNameRequest; |
||||
using grpc::reflection::v1alpha::SymbolRequest; |
||||
using grpc::reflection::v1alpha::ExtensionRequest; |
||||
using grpc::reflection::v1alpha::TypeRequest; |
||||
using grpc::reflection::v1alpha::FileDescriptorProtoResponse; |
||||
using grpc::reflection::v1alpha::ExtensionNumberResponse; |
||||
|
||||
namespace grpc { |
||||
|
||||
ProtoServerReflection::ProtoServerReflection() |
||||
: descriptor_pool_(DescriptorPool::generated_pool()) {} |
||||
|
||||
void ProtoServerReflection::SetServiceList( |
||||
const std::vector<grpc::string>* services) { |
||||
services_ = services; |
||||
} |
||||
|
||||
Status ProtoServerReflection::ListService(ServerContext* context, |
||||
const EmptyRequest* request, |
||||
ListServiceResponse* response) { |
||||
if (services_ == nullptr) { |
||||
return Status(StatusCode::NOT_FOUND, "Services not found."); |
||||
} |
||||
for (auto it = services_->begin(); it != services_->end(); ++it) { |
||||
response->add_services(*it); |
||||
} |
||||
return Status::OK; |
||||
} |
||||
|
||||
Status ProtoServerReflection::GetFileByName( |
||||
ServerContext* context, const FileNameRequest* request, |
||||
FileDescriptorProtoResponse* response) { |
||||
if (descriptor_pool_ == nullptr) { |
||||
return Status::CANCELLED; |
||||
} |
||||
|
||||
const FileDescriptor* file_desc = |
||||
descriptor_pool_->FindFileByName(request->filename()); |
||||
if (file_desc == nullptr) { |
||||
return Status(StatusCode::NOT_FOUND, "File not found."); |
||||
} |
||||
FillFileDescriptorProtoResponse(file_desc, response); |
||||
// file_desc->CopyTo(response->mutable_file_descriptor_proto());
|
||||
return Status::OK; |
||||
} |
||||
|
||||
Status ProtoServerReflection::GetFileContainingSymbol( |
||||
ServerContext* context, const SymbolRequest* request, |
||||
FileDescriptorProtoResponse* response) { |
||||
if (descriptor_pool_ == nullptr) { |
||||
return Status::CANCELLED; |
||||
} |
||||
|
||||
const FileDescriptor* file_desc = |
||||
descriptor_pool_->FindFileContainingSymbol(request->symbol()); |
||||
if (file_desc == nullptr) { |
||||
return Status(StatusCode::NOT_FOUND, "Symbol not found."); |
||||
} |
||||
FillFileDescriptorProtoResponse(file_desc, response); |
||||
// file_desc->CopyTo(response->mutable_file_descriptor_proto());
|
||||
return Status::OK; |
||||
} |
||||
|
||||
Status ProtoServerReflection::GetFileContainingExtension( |
||||
ServerContext* context, const ExtensionRequest* request, |
||||
FileDescriptorProtoResponse* response) { |
||||
if (descriptor_pool_ == nullptr) { |
||||
return Status::CANCELLED; |
||||
} |
||||
|
||||
const Descriptor* desc = |
||||
descriptor_pool_->FindMessageTypeByName(request->containing_type()); |
||||
if (desc == nullptr) { |
||||
return Status(StatusCode::NOT_FOUND, "Type not found."); |
||||
} |
||||
|
||||
const FieldDescriptor* field_desc = descriptor_pool_->FindExtensionByNumber( |
||||
desc, request->extension_number()); |
||||
if (field_desc == nullptr) { |
||||
return Status(StatusCode::NOT_FOUND, "Extension not found."); |
||||
} |
||||
FillFileDescriptorProtoResponse(field_desc->file(), response); |
||||
// field_desc->file()->CopyTo(response->mutable_file_descriptor_proto());
|
||||
return Status::OK; |
||||
} |
||||
|
||||
Status ProtoServerReflection::GetAllExtensionNumbers( |
||||
ServerContext* context, const TypeRequest* request, |
||||
ExtensionNumberResponse* response) { |
||||
if (descriptor_pool_ == nullptr) { |
||||
return Status::CANCELLED; |
||||
} |
||||
|
||||
const Descriptor* desc = |
||||
descriptor_pool_->FindMessageTypeByName(request->type()); |
||||
if (desc == nullptr) { |
||||
return Status(StatusCode::NOT_FOUND, "Type not found."); |
||||
} |
||||
|
||||
std::vector<const FieldDescriptor*> extensions; |
||||
descriptor_pool_->FindAllExtensions(desc, &extensions); |
||||
for (auto extension : extensions) { |
||||
response->add_extension_number(extension->number()); |
||||
} |
||||
return Status::OK; |
||||
} |
||||
|
||||
void ProtoServerReflection::FillFileDescriptorProtoResponse( |
||||
const FileDescriptor* file_desc, FileDescriptorProtoResponse* response) { |
||||
FileDescriptorProto file_desc_proto; |
||||
grpc::string data; |
||||
file_desc->CopyTo(&file_desc_proto); |
||||
file_desc_proto.SerializeToString(&data); |
||||
response->set_file_descriptor_proto(data); |
||||
} |
||||
|
||||
} // namespace grpc
|
@ -0,0 +1,92 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_EXTENSIONS_REFLECTION_PROTO_SERVER_REFLECTION_H |
||||
#define GRPC_EXTENSIONS_REFLECTION_PROTO_SERVER_REFLECTION_H |
||||
|
||||
#include <iostream> |
||||
#include <memory> |
||||
#include <string> |
||||
#include <vector> |
||||
|
||||
#include <google/protobuf/descriptor.h> |
||||
#include <google/protobuf/descriptor.pb.h> |
||||
#include <grpc++/grpc++.h> |
||||
|
||||
#include <grpc++/impl/reflection.grpc.pb.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
class ProtoServerReflection GRPC_FINAL |
||||
: public reflection::v1alpha::ServerReflection::Service { |
||||
public: |
||||
ProtoServerReflection(); |
||||
|
||||
ProtoServerReflection(const Server* server); |
||||
|
||||
void SetServiceList(const std::vector<grpc::string>* services); |
||||
|
||||
Status ListService( |
||||
ServerContext* context, const reflection::v1alpha::EmptyRequest* request, |
||||
reflection::v1alpha::ListServiceResponse* response) GRPC_OVERRIDE; |
||||
|
||||
Status GetFileByName( |
||||
ServerContext* context, |
||||
const reflection::v1alpha::FileNameRequest* request, |
||||
reflection::v1alpha::FileDescriptorProtoResponse* response) GRPC_OVERRIDE; |
||||
|
||||
Status GetFileContainingSymbol( |
||||
ServerContext* context, const reflection::v1alpha::SymbolRequest* request, |
||||
reflection::v1alpha::FileDescriptorProtoResponse* response) GRPC_OVERRIDE; |
||||
|
||||
Status GetFileContainingExtension( |
||||
ServerContext* context, |
||||
const reflection::v1alpha::ExtensionRequest* request, |
||||
reflection::v1alpha::FileDescriptorProtoResponse* response) GRPC_OVERRIDE; |
||||
|
||||
Status GetAllExtensionNumbers( |
||||
ServerContext* context, const reflection::v1alpha::TypeRequest* request, |
||||
reflection::v1alpha::ExtensionNumberResponse* response) GRPC_OVERRIDE; |
||||
|
||||
private: |
||||
void FillFileDescriptorProtoResponse( |
||||
const google::protobuf::FileDescriptor* file_desc, |
||||
reflection::v1alpha::FileDescriptorProtoResponse* response); |
||||
|
||||
const google::protobuf::DescriptorPool* descriptor_pool_; |
||||
const std::vector<string>* services_; |
||||
}; |
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPC_EXTENSIONS_REFLECTION_PROTO_SERVER_REFLECTION_H
|
@ -0,0 +1,89 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc++/impl/proto_server_reflection_plugin.h> |
||||
#include <grpc++/impl/server_builder_plugin.h> |
||||
#include <grpc++/impl/server_initializer.h> |
||||
#include <grpc++/server.h> |
||||
|
||||
#include "reflection/proto_server_reflection.h" |
||||
|
||||
namespace grpc { |
||||
namespace reflection { |
||||
|
||||
ProtoServerReflectionPlugin::ProtoServerReflectionPlugin() |
||||
: reflection_service(new grpc::ProtoServerReflection()) {} |
||||
|
||||
grpc::string ProtoServerReflectionPlugin::name() { return "p1"; } |
||||
|
||||
void ProtoServerReflectionPlugin::InitServer(grpc::ServerInitializer* si) { |
||||
si->RegisterService(reflection_service); |
||||
} |
||||
|
||||
void ProtoServerReflectionPlugin::Finish(grpc::ServerInitializer* si) { |
||||
reflection_service->SetServiceList(si->GetServiceList()); |
||||
} |
||||
|
||||
void ProtoServerReflectionPlugin::ChangeArguments(const grpc::string& name, |
||||
void* value) {} |
||||
|
||||
bool ProtoServerReflectionPlugin::has_sync_methods() const { |
||||
if (reflection_service != nullptr) { |
||||
return reflection_service->has_synchronous_methods(); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
bool ProtoServerReflectionPlugin::has_async_methods() const { |
||||
if (reflection_service != nullptr) { |
||||
return reflection_service->has_async_methods(); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void grpc_AddServerBuilderPlugin_reflection() { |
||||
static bool already_here = false; |
||||
if (already_here) return; |
||||
already_here = true; |
||||
::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
|
@ -0,0 +1,245 @@ |
||||
// Generated by the gRPC protobuf plugin.
|
||||
// If you make any local change, they will be lost.
|
||||
// source: reflection.proto
|
||||
|
||||
#include <grpc++/impl/reflection.grpc.pb.h> |
||||
#include <grpc++/impl/reflection.pb.h> |
||||
|
||||
#include <grpc++/impl/codegen/async_stream.h> |
||||
#include <grpc++/impl/codegen/async_unary_call.h> |
||||
#include <grpc++/impl/codegen/channel_interface.h> |
||||
#include <grpc++/impl/codegen/client_unary_call.h> |
||||
#include <grpc++/impl/codegen/method_handler_impl.h> |
||||
#include <grpc++/impl/codegen/rpc_service_method.h> |
||||
#include <grpc++/impl/codegen/service_type.h> |
||||
#include <grpc++/impl/codegen/sync_stream.h> |
||||
namespace grpc { |
||||
namespace reflection { |
||||
namespace v1alpha { |
||||
|
||||
static const char* ServerReflection_method_names[] = { |
||||
"/grpc.reflection.v1alpha.ServerReflection/ListService", |
||||
"/grpc.reflection.v1alpha.ServerReflection/GetFileByName", |
||||
"/grpc.reflection.v1alpha.ServerReflection/GetFileContainingSymbol", |
||||
"/grpc.reflection.v1alpha.ServerReflection/GetFileContainingExtension", |
||||
"/grpc.reflection.v1alpha.ServerReflection/GetAllExtensionNumbers", |
||||
}; |
||||
|
||||
std::unique_ptr<ServerReflection::Stub> ServerReflection::NewStub( |
||||
const std::shared_ptr< ::grpc::ChannelInterface>& channel, |
||||
const ::grpc::StubOptions& options) { |
||||
std::unique_ptr<ServerReflection::Stub> stub( |
||||
new ServerReflection::Stub(channel)); |
||||
return stub; |
||||
} |
||||
|
||||
ServerReflection::Stub::Stub( |
||||
const std::shared_ptr< ::grpc::ChannelInterface>& channel) |
||||
: channel_(channel), |
||||
rpcmethod_ListService_(ServerReflection_method_names[0], |
||||
::grpc::RpcMethod::NORMAL_RPC, channel), |
||||
rpcmethod_GetFileByName_(ServerReflection_method_names[1], |
||||
::grpc::RpcMethod::NORMAL_RPC, channel), |
||||
rpcmethod_GetFileContainingSymbol_(ServerReflection_method_names[2], |
||||
::grpc::RpcMethod::NORMAL_RPC, |
||||
channel), |
||||
rpcmethod_GetFileContainingExtension_(ServerReflection_method_names[3], |
||||
::grpc::RpcMethod::NORMAL_RPC, |
||||
channel), |
||||
rpcmethod_GetAllExtensionNumbers_(ServerReflection_method_names[4], |
||||
::grpc::RpcMethod::NORMAL_RPC, |
||||
channel) {} |
||||
|
||||
::grpc::Status ServerReflection::Stub::ListService( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response) { |
||||
return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_ListService_, |
||||
context, request, response); |
||||
} |
||||
|
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>* |
||||
ServerReflection::Stub::AsyncListServiceRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return new ::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ListServiceResponse>( |
||||
channel_.get(), cq, rpcmethod_ListService_, context, request); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Stub::GetFileByName( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_GetFileByName_, |
||||
context, request, response); |
||||
} |
||||
|
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
ServerReflection::Stub::AsyncGetFileByNameRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return new ::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>( |
||||
channel_.get(), cq, rpcmethod_GetFileByName_, context, request); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Stub::GetFileContainingSymbol( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
return ::grpc::BlockingUnaryCall(channel_.get(), |
||||
rpcmethod_GetFileContainingSymbol_, context, |
||||
request, response); |
||||
} |
||||
|
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
ServerReflection::Stub::AsyncGetFileContainingSymbolRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return new ::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>( |
||||
channel_.get(), cq, rpcmethod_GetFileContainingSymbol_, context, request); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Stub::GetFileContainingExtension( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
return ::grpc::BlockingUnaryCall(channel_.get(), |
||||
rpcmethod_GetFileContainingExtension_, |
||||
context, request, response); |
||||
} |
||||
|
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>* |
||||
ServerReflection::Stub::AsyncGetFileContainingExtensionRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return new ::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>( |
||||
channel_.get(), cq, rpcmethod_GetFileContainingExtension_, context, |
||||
request); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Stub::GetAllExtensionNumbers( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response) { |
||||
return ::grpc::BlockingUnaryCall(channel_.get(), |
||||
rpcmethod_GetAllExtensionNumbers_, context, |
||||
request, response); |
||||
} |
||||
|
||||
::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>* |
||||
ServerReflection::Stub::AsyncGetAllExtensionNumbersRaw( |
||||
::grpc::ClientContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest& request, |
||||
::grpc::CompletionQueue* cq) { |
||||
return new ::grpc::ClientAsyncResponseReader< |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>( |
||||
channel_.get(), cq, rpcmethod_GetAllExtensionNumbers_, context, request); |
||||
} |
||||
|
||||
ServerReflection::Service::Service() { |
||||
(void)ServerReflection_method_names; |
||||
AddMethod(new ::grpc::RpcServiceMethod( |
||||
ServerReflection_method_names[0], ::grpc::RpcMethod::NORMAL_RPC, |
||||
new ::grpc::RpcMethodHandler< |
||||
ServerReflection::Service, ::grpc::reflection::v1alpha::EmptyRequest, |
||||
::grpc::reflection::v1alpha::ListServiceResponse>( |
||||
std::mem_fn(&ServerReflection::Service::ListService), this))); |
||||
AddMethod(new ::grpc::RpcServiceMethod( |
||||
ServerReflection_method_names[1], ::grpc::RpcMethod::NORMAL_RPC, |
||||
new ::grpc::RpcMethodHandler< |
||||
ServerReflection::Service, |
||||
::grpc::reflection::v1alpha::FileNameRequest, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>( |
||||
std::mem_fn(&ServerReflection::Service::GetFileByName), this))); |
||||
AddMethod(new ::grpc::RpcServiceMethod( |
||||
ServerReflection_method_names[2], ::grpc::RpcMethod::NORMAL_RPC, |
||||
new ::grpc::RpcMethodHandler< |
||||
ServerReflection::Service, ::grpc::reflection::v1alpha::SymbolRequest, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>( |
||||
std::mem_fn(&ServerReflection::Service::GetFileContainingSymbol), |
||||
this))); |
||||
AddMethod(new ::grpc::RpcServiceMethod( |
||||
ServerReflection_method_names[3], ::grpc::RpcMethod::NORMAL_RPC, |
||||
new ::grpc::RpcMethodHandler< |
||||
ServerReflection::Service, |
||||
::grpc::reflection::v1alpha::ExtensionRequest, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse>( |
||||
std::mem_fn(&ServerReflection::Service::GetFileContainingExtension), |
||||
this))); |
||||
AddMethod(new ::grpc::RpcServiceMethod( |
||||
ServerReflection_method_names[4], ::grpc::RpcMethod::NORMAL_RPC, |
||||
new ::grpc::RpcMethodHandler< |
||||
ServerReflection::Service, ::grpc::reflection::v1alpha::TypeRequest, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse>( |
||||
std::mem_fn(&ServerReflection::Service::GetAllExtensionNumbers), |
||||
this))); |
||||
} |
||||
|
||||
ServerReflection::Service::~Service() {} |
||||
|
||||
::grpc::Status ServerReflection::Service::ListService( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::EmptyRequest* request, |
||||
::grpc::reflection::v1alpha::ListServiceResponse* response) { |
||||
(void)context; |
||||
(void)request; |
||||
(void)response; |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Service::GetFileByName( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::FileNameRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
(void)context; |
||||
(void)request; |
||||
(void)response; |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Service::GetFileContainingSymbol( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::SymbolRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
(void)context; |
||||
(void)request; |
||||
(void)response; |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Service::GetFileContainingExtension( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::ExtensionRequest* request, |
||||
::grpc::reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
(void)context; |
||||
(void)request; |
||||
(void)response; |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
|
||||
::grpc::Status ServerReflection::Service::GetAllExtensionNumbers( |
||||
::grpc::ServerContext* context, |
||||
const ::grpc::reflection::v1alpha::TypeRequest* request, |
||||
::grpc::reflection::v1alpha::ExtensionNumberResponse* response) { |
||||
(void)context; |
||||
(void)request; |
||||
(void)response; |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
|
||||
} // namespace grpc
|
||||
} // namespace reflection
|
||||
} // namespace v1alpha
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,118 @@ |
||||
// Copyright 2016, Google Inc. |
||||
// All rights reserved. |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
// Service exported by server reflection |
||||
|
||||
syntax = "proto3"; |
||||
|
||||
package grpc.reflection.v1alpha; |
||||
|
||||
service ServerReflection { |
||||
// List the full names of registered services. |
||||
rpc ListService(EmptyRequest) returns (ListServiceResponse) { |
||||
} |
||||
|
||||
// Find a proto file by file name. |
||||
rpc GetFileByName(FileNameRequest) returns (FileDescriptorProtoResponse) { |
||||
} |
||||
|
||||
// Find the proto file that declares the given fully-qualified symbol name. |
||||
rpc GetFileContainingSymbol(SymbolRequest) |
||||
returns (FileDescriptorProtoResponse) { |
||||
} |
||||
|
||||
// Find the proto file which defines an extension extending the given message |
||||
// type with the given field number. |
||||
rpc GetFileContainingExtension(ExtensionRequest) |
||||
returns (FileDescriptorProtoResponse) { |
||||
} |
||||
|
||||
// Finds the tag numbers used by all known extensions of extendee_type, and |
||||
// appends them to ExtensionNumberResponse in an undefined order. |
||||
// This method is best-effort: it's not guaranteed that the reflection service |
||||
// will implement this method, and it's not guaranteed that this method will |
||||
// provide all extensions. Returns StatusCode::UNIMPLEMENTED if it's not |
||||
// implemented. |
||||
rpc GetAllExtensionNumbers(TypeRequest) returns (ExtensionNumberResponse) { |
||||
} |
||||
} |
||||
|
||||
// An empty message sent by the client when calling ListService method. |
||||
message EmptyRequest { |
||||
} |
||||
|
||||
// The filename sent by the client when calling GetFileByName method. |
||||
message FileNameRequest { |
||||
// Name of the proto file. |
||||
string filename = 1; |
||||
} |
||||
|
||||
// The symbol name sent by the client when calling GetFileContainingSymbol |
||||
// method. |
||||
message SymbolRequest { |
||||
// Fully-qualified symbol name (e.g. <package>.<service>[.<method>] or |
||||
// <package>.<type>). |
||||
string symbol = 1; |
||||
} |
||||
|
||||
// The type name and extension number sent by the client when calling |
||||
// GetFileContainingExtension method. |
||||
message ExtensionRequest { |
||||
// Fully-qualified type name. The format should be <package>.<type> |
||||
string containing_type = 1; |
||||
int32 extension_number = 2; |
||||
} |
||||
|
||||
// The type name sent by the client when calling GetAllExtensionNumbers method. |
||||
message TypeRequest { |
||||
// Fully-qualified type name. The format should be <package>.<type> |
||||
string type = 1; |
||||
} |
||||
|
||||
// A list of service names sent by the server answering ListService method. |
||||
message ListServiceResponse { |
||||
// Full names of registered services, including package names. The format |
||||
// is <package>.<service> |
||||
repeated string services = 1; |
||||
} |
||||
|
||||
// A serialized FileDescriptorProto sent by the server answering |
||||
// GetFileByName, GetFileContainingSymbol, GetFileContainingExtension methods. |
||||
message FileDescriptorProtoResponse { |
||||
// Serialized FileDescriptorProto message. Some languages have limited support |
||||
// for working with descriptors. The can only obtain an opaque binary blob |
||||
// that contains serialized FileDescriptorProto message. |
||||
bytes file_descriptor_proto = 1; |
||||
} |
||||
|
||||
// A list of extension numbers sent by the server answering |
||||
// GetAllExtensionNumbers method. |
||||
message ExtensionNumberResponse { |
||||
repeated int32 extension_number = 1; |
||||
} |
@ -0,0 +1,238 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include "proto_reflection_descriptor_database.h" |
||||
|
||||
#include <vector> |
||||
|
||||
#include <grpc/support/log.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase( |
||||
std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub) |
||||
: stub_(std::move(stub)) {} |
||||
|
||||
ProtoReflectionDescriptorDatabase::ProtoReflectionDescriptorDatabase( |
||||
std::shared_ptr<grpc::Channel> channel) |
||||
: stub_(reflection::v1alpha::ServerReflection::NewStub(channel)) {} |
||||
|
||||
ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {} |
||||
|
||||
bool ProtoReflectionDescriptorDatabase::FindFileByName( |
||||
const string& filename, google::protobuf::FileDescriptorProto* output) { |
||||
if (cached_db_.FindFileByName(filename, output)) { |
||||
return true; |
||||
} |
||||
|
||||
if (known_files_.find(filename) != known_files_.end()) { |
||||
return false; |
||||
} |
||||
|
||||
ClientContext ctx; |
||||
reflection::v1alpha::FileNameRequest request; |
||||
request.set_filename(filename); |
||||
reflection::v1alpha::FileDescriptorProtoResponse response; |
||||
|
||||
Status status = stub_->GetFileByName(&ctx, request, &response); |
||||
if (status.ok()) { |
||||
// const google::protobuf::FileDescriptorProto* file_proto =
|
||||
// response.mutable_file_descriptor_proto();
|
||||
const google::protobuf::FileDescriptorProto file_proto = |
||||
ParseFileDescriptorProtoResponse(&response); |
||||
known_files_.insert(file_proto.name()); |
||||
cached_db_.Add(file_proto); |
||||
} else if (status.error_code() == StatusCode::NOT_FOUND) { |
||||
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)", |
||||
filename.c_str()); |
||||
} else { |
||||
gpr_log(GPR_INFO, |
||||
"Error on FindFileByName(%s)\n\tError code: %d\n" |
||||
"\tError Message: %s", |
||||
filename.c_str(), status.error_code(), |
||||
status.error_message().c_str()); |
||||
} |
||||
|
||||
return cached_db_.FindFileByName(filename, output); |
||||
} |
||||
|
||||
bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol( |
||||
const string& symbol_name, google::protobuf::FileDescriptorProto* output) { |
||||
if (cached_db_.FindFileContainingSymbol(symbol_name, output)) { |
||||
return true; |
||||
} |
||||
|
||||
if (missing_symbols_.find(symbol_name) != missing_symbols_.end()) { |
||||
return false; |
||||
} |
||||
|
||||
ClientContext ctx; |
||||
reflection::v1alpha::SymbolRequest request; |
||||
request.set_symbol(symbol_name); |
||||
reflection::v1alpha::FileDescriptorProtoResponse response; |
||||
|
||||
Status status = stub_->GetFileContainingSymbol(&ctx, request, &response); |
||||
if (status.ok()) { |
||||
const google::protobuf::FileDescriptorProto file_proto = |
||||
ParseFileDescriptorProtoResponse(&response); |
||||
if (known_files_.find(file_proto.name()) == known_files_.end()) { |
||||
known_files_.insert(file_proto.name()); |
||||
cached_db_.Add(file_proto); |
||||
} |
||||
} else if (status.error_code() == StatusCode::NOT_FOUND) { |
||||
missing_symbols_.insert(symbol_name); |
||||
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileContainingSymbol(%s)", |
||||
symbol_name.c_str()); |
||||
} else { |
||||
gpr_log(GPR_INFO, |
||||
"Error on FindFileContainingSymbol(%s)\n" |
||||
"\tError code: %d\n\tError Message: %s", |
||||
symbol_name.c_str(), status.error_code(), |
||||
status.error_message().c_str()); |
||||
} |
||||
|
||||
return cached_db_.FindFileContainingSymbol(symbol_name, output); |
||||
} |
||||
|
||||
bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension( |
||||
const string& containing_type, int field_number, |
||||
google::protobuf::FileDescriptorProto* output) { |
||||
if (cached_db_.FindFileContainingExtension(containing_type, field_number, |
||||
output)) { |
||||
return true; |
||||
} |
||||
|
||||
if (missing_extensions_.find(containing_type) != missing_extensions_.end() && |
||||
missing_extensions_[containing_type].find(field_number) != |
||||
missing_extensions_[containing_type].end()) { |
||||
gpr_log(GPR_INFO, "nested map."); |
||||
return false; |
||||
} |
||||
|
||||
ClientContext ctx; |
||||
reflection::v1alpha::ExtensionRequest request; |
||||
request.set_containing_type(containing_type); |
||||
request.set_extension_number(field_number); |
||||
reflection::v1alpha::FileDescriptorProtoResponse response; |
||||
|
||||
Status status = stub_->GetFileContainingExtension(&ctx, request, &response); |
||||
if (status.ok()) { |
||||
const google::protobuf::FileDescriptorProto file_proto = |
||||
ParseFileDescriptorProtoResponse(&response); |
||||
if (known_files_.find(file_proto.name()) == known_files_.end()) { |
||||
known_files_.insert(file_proto.name()); |
||||
cached_db_.Add(file_proto); |
||||
} |
||||
} else if (status.error_code() == StatusCode::NOT_FOUND) { |
||||
if (missing_extensions_.find(containing_type) == |
||||
missing_extensions_.end()) { |
||||
missing_extensions_[containing_type] = {}; |
||||
} |
||||
missing_extensions_[containing_type].insert(field_number); |
||||
gpr_log(GPR_INFO, |
||||
"NOT_FOUND from server for FindFileContainingExtension(%s, %d)", |
||||
containing_type.c_str(), field_number); |
||||
} else { |
||||
gpr_log(GPR_INFO, |
||||
"Error on FindFileContainingExtension(%s, %d)\n" |
||||
"\tError code: %d\n\tError Message: %s", |
||||
containing_type.c_str(), field_number, status.error_code(), |
||||
status.error_message().c_str()); |
||||
} |
||||
|
||||
return cached_db_.FindFileContainingExtension(containing_type, field_number, |
||||
output); |
||||
} |
||||
|
||||
bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers( |
||||
const string& extendee_type, std::vector<int>* output) { |
||||
if (cached_extension_numbers_.find(extendee_type) != |
||||
cached_extension_numbers_.end()) { |
||||
*output = cached_extension_numbers_[extendee_type]; |
||||
return true; |
||||
} |
||||
|
||||
ClientContext ctx; |
||||
reflection::v1alpha::TypeRequest request; |
||||
request.set_type(extendee_type); |
||||
reflection::v1alpha::ExtensionNumberResponse response; |
||||
|
||||
Status status = stub_->GetAllExtensionNumbers(&ctx, request, &response); |
||||
if (status.ok()) { |
||||
auto number = response.extension_number(); |
||||
*output = std::vector<int>(number.begin(), number.end()); |
||||
cached_extension_numbers_[extendee_type] = *output; |
||||
return true; |
||||
} else if (status.error_code() == StatusCode::NOT_FOUND) { |
||||
gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)", |
||||
extendee_type.c_str()); |
||||
} else { |
||||
gpr_log(GPR_INFO, |
||||
"Error on FindAllExtensionNumbersExtension(%s)\n" |
||||
"\tError code: %d\n\tError Message: %s", |
||||
extendee_type.c_str(), status.error_code(), |
||||
status.error_message().c_str()); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
bool ProtoReflectionDescriptorDatabase::GetServices( |
||||
std::vector<std::string>* output) { |
||||
ClientContext ctx; |
||||
reflection::v1alpha::EmptyRequest request; |
||||
reflection::v1alpha::ListServiceResponse response; |
||||
|
||||
Status status = stub_->ListService(&ctx, request, &response); |
||||
if (status.ok()) { |
||||
for (int i = 0; i < response.services_size(); ++i) { |
||||
(*output).push_back(response.services(i)); |
||||
} |
||||
return true; |
||||
} else { |
||||
gpr_log(GPR_INFO, |
||||
"Error on GetServices()\n\tError code: %d\n" |
||||
"\tError Message: %s", |
||||
status.error_code(), status.error_message().c_str()); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
const google::protobuf::FileDescriptorProto |
||||
ProtoReflectionDescriptorDatabase::ParseFileDescriptorProtoResponse( |
||||
reflection::v1alpha::FileDescriptorProtoResponse* response) { |
||||
google::protobuf::FileDescriptorProto file_desc_proto; |
||||
file_desc_proto.ParseFromString(response->file_descriptor_proto()); |
||||
return file_desc_proto; |
||||
} |
||||
|
||||
} // namespace grpc
|
@ -0,0 +1,95 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <memory> |
||||
#include <unordered_map> |
||||
#include <unordered_set> |
||||
#include <vector> |
||||
|
||||
#include <google/protobuf/descriptor.h> |
||||
#include <google/protobuf/descriptor.pb.h> |
||||
#include <google/protobuf/descriptor_database.h> |
||||
#include <grpc++/grpc++.h> |
||||
#include <grpc++/impl/reflection.grpc.pb.h> |
||||
|
||||
// #include "reflection.grpc.pb.h"
|
||||
|
||||
namespace grpc { |
||||
|
||||
class ProtoReflectionDescriptorDatabase |
||||
: public google::protobuf::DescriptorDatabase { |
||||
public: |
||||
explicit ProtoReflectionDescriptorDatabase( |
||||
std::unique_ptr<reflection::v1alpha::ServerReflection::Stub> stub); |
||||
|
||||
explicit ProtoReflectionDescriptorDatabase( |
||||
std::shared_ptr<grpc::Channel> channel); |
||||
|
||||
virtual ~ProtoReflectionDescriptorDatabase(); |
||||
|
||||
// DescriptorDatabase methods
|
||||
bool FindFileByName(const string& filename, |
||||
google::protobuf::FileDescriptorProto* output) |
||||
GRPC_OVERRIDE; |
||||
|
||||
bool FindFileContainingSymbol(const string& symbol_name, |
||||
google::protobuf::FileDescriptorProto* output) |
||||
GRPC_OVERRIDE; |
||||
|
||||
bool FindFileContainingExtension( |
||||
const string& containing_type, int field_number, |
||||
google::protobuf::FileDescriptorProto* output) GRPC_OVERRIDE; |
||||
|
||||
bool FindAllExtensionNumbers(const string& extendee_type, |
||||
std::vector<int>* output) GRPC_OVERRIDE; |
||||
|
||||
bool GetServices(std::vector<std::string>* output); |
||||
|
||||
grpc::reflection::v1alpha::ServerReflection::Stub* stub() { |
||||
return stub_.get(); |
||||
} |
||||
|
||||
private: |
||||
const google::protobuf::FileDescriptorProto ParseFileDescriptorProtoResponse( |
||||
reflection::v1alpha::FileDescriptorProtoResponse* response); |
||||
|
||||
std::unique_ptr<grpc::reflection::v1alpha::ServerReflection::Stub> stub_; |
||||
std::unordered_set<string> known_files_; |
||||
std::unordered_set<string> missing_symbols_; |
||||
std::unordered_map<string, std::unordered_set<int>> missing_extensions_; |
||||
std::unordered_map<string, std::vector<int>> cached_extension_numbers_; |
||||
|
||||
google::protobuf::SimpleDescriptorDatabase cached_db_; |
||||
}; |
||||
|
||||
} // namespace grpc
|
@ -0,0 +1,50 @@ |
||||
|
||||
# Copyright 2015-2016, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
CXX = g++
|
||||
INCLUDES += -I. -I..
|
||||
CPPFLAGS += -I/usr/local/include -pthread
|
||||
CXXFLAGS += -std=c++11 ${INCLUDES}
|
||||
LDFLAGS += -L/usr/local/lib -lgrpc++_unsecure -lgrpc -lgrpc++_reflection -lprotobuf -lpthread -ldl
|
||||
VPATH = ..
|
||||
|
||||
# PROTOS_PATH = ../../../src/cpp/plugin/reflection
|
||||
|
||||
vpath %.proto $(PROTOS_PATH) |
||||
|
||||
all: reflection_client |
||||
|
||||
reflection_client: proto_reflection_descriptor_database.o reflection_client.o |
||||
$(CXX) $(INCLUDES) $^ $(LDFLAGS) -o $@
|
||||
|
||||
|
||||
clean: |
||||
rm -f *.o reflection_client
|
@ -0,0 +1,216 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <iomanip> |
||||
#include <iostream> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include <google/protobuf/descriptor.h> |
||||
#include <google/protobuf/descriptor.pb.h> |
||||
#include <grpc++/grpc++.h> |
||||
|
||||
#include "proto_reflection_descriptor_database.h" |
||||
// #include "reflection.grpc.pb.h"
|
||||
|
||||
using grpc::Channel; |
||||
using grpc::ClientContext; |
||||
using grpc::Status; |
||||
using grpc::ProtoReflectionDescriptorDatabase; |
||||
using grpc::reflection::v1alpha::ServerReflection; |
||||
using grpc::reflection::v1alpha::EmptyRequest; |
||||
using grpc::reflection::v1alpha::ListServiceResponse; |
||||
using google::protobuf::FileDescriptorProto; |
||||
using google::protobuf::DescriptorPool; |
||||
using google::protobuf::ServiceDescriptor; |
||||
using google::protobuf::MethodDescriptor; |
||||
using google::protobuf::Descriptor; |
||||
using google::protobuf::FieldDescriptor; |
||||
|
||||
class ReflectionClient { |
||||
public: |
||||
ReflectionClient(std::shared_ptr<Channel> channel) |
||||
: db_(new ProtoReflectionDescriptorDatabase( |
||||
ServerReflection::NewStub(channel))), |
||||
desc_pool_(new DescriptorPool(db_.get())) {} |
||||
|
||||
void PrintInfo() { |
||||
EmptyRequest request; |
||||
ListServiceResponse response; |
||||
ClientContext context; |
||||
Status status = db_->stub()->ListService(&context, request, &response); |
||||
if (status.ok()) { |
||||
std::string padding = ""; |
||||
std::cout << "Service amount:" << response.services_size() << std::endl; |
||||
for (int i = 0; i < response.services_size(); ++i) { |
||||
if (i != response.services_size() - 1) { |
||||
std::cout << padding << "│ " << std::endl; |
||||
std::cout << padding << "├─" << response.services(i) << std::endl; |
||||
PrintService(desc_pool_->FindServiceByName(response.services(i)), |
||||
padding + "│ "); |
||||
} else { |
||||
std::cout << padding << "│ " << std::endl; |
||||
std::cout << padding << "└─" << response.services(i) << std::endl; |
||||
PrintService(desc_pool_->FindServiceByName(response.services(i)), |
||||
padding + " "); |
||||
} |
||||
} |
||||
} else { |
||||
std::cout << status.error_message(); |
||||
} |
||||
} |
||||
|
||||
void PrintService(const ServiceDescriptor* service_desc, |
||||
const std::string padding) { |
||||
if (service_desc != nullptr) { |
||||
std::cout << padding << "│ Method amount:" << service_desc->method_count() |
||||
<< std::endl; |
||||
for (int i = 0; i < service_desc->method_count(); ++i) { |
||||
if (i != service_desc->method_count() - 1) { |
||||
std::cout << padding << "├─" << service_desc->method(i)->name() |
||||
<< std::endl; |
||||
PrintMethod(service_desc->method(i), padding + "│ "); |
||||
} else { |
||||
std::cout << padding << "└─" << service_desc->method(i)->name() |
||||
<< std::endl; |
||||
PrintMethod(service_desc->method(i), padding + " "); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PrintMethod(const MethodDescriptor* method_desc, |
||||
const std::string padding) { |
||||
if (method_desc != nullptr) { |
||||
std::cout << padding |
||||
<< "├─input type: " << method_desc->input_type()->name() |
||||
<< std::endl; |
||||
PrintMessageType(method_desc->input_type(), padding + "│ "); |
||||
std::cout << padding |
||||
<< "└─output type: " << method_desc->output_type()->name() |
||||
<< std::endl; |
||||
PrintMessageType(method_desc->output_type(), padding + " "); |
||||
} |
||||
} |
||||
|
||||
void PrintMessageType(const Descriptor* type_desc, |
||||
const std::string padding) { |
||||
if (type_desc != nullptr) { |
||||
if (type_desc->field_count() > 0) { |
||||
std::cout << padding << "│ Field amount:" << type_desc->field_count() |
||||
<< std::endl; |
||||
} |
||||
for (int i = 0; i < type_desc->field_count(); ++i) { |
||||
if (i != type_desc->field_count() - 1) { |
||||
const FieldDescriptor* field = type_desc->field(i); |
||||
std::cout << padding << "├─ " << std::left << std::setw(15) |
||||
<< kLabelToName[field->label()] << std::setw(30) |
||||
<< " name: " + field->name() << std::setw(50) |
||||
<< " type: " + |
||||
(field->type() == FieldDescriptor::Type::TYPE_MESSAGE |
||||
? field->message_type()->name() |
||||
: field->type_name()) |
||||
<< std::endl; |
||||
} else { |
||||
const FieldDescriptor* field = type_desc->field(i); |
||||
std::cout << padding << "└─ " << std::left << std::setw(15) |
||||
<< kLabelToName[field->label()] << std::setw(30) |
||||
<< " name: " + field->name() << std::setw(50) |
||||
<< " type: " + |
||||
(field->type() == FieldDescriptor::Type::TYPE_MESSAGE |
||||
? field->message_type()->name() |
||||
: field->type_name()) |
||||
<< std::endl; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void Test() { |
||||
{ |
||||
FileDescriptorProto output; |
||||
bool found = db_->FindFileByName("helloworld.proto", &output); |
||||
if (found) std::cout << output.name() << std::endl; |
||||
} |
||||
{ |
||||
FileDescriptorProto output; |
||||
bool found = |
||||
db_->FindFileContainingSymbol("helloworld.Greeter.SayHello", &output); |
||||
if (found) std::cout << output.name() << std::endl; |
||||
} |
||||
{ |
||||
FileDescriptorProto output; |
||||
bool found = db_->FindFileContainingExtension( |
||||
"helloworld.Greeter.HelloRequest", 1, &output); |
||||
found = db_->FindFileContainingExtension( |
||||
"helloworld.Greeter.HelloRequest", 1, &output); |
||||
if (found) std::cout << output.name() << std::endl; |
||||
} |
||||
DescriptorPool pool(db_.get()); |
||||
std::cout << pool.FindServiceByName("helloworld.Greeter")->name() |
||||
<< std::endl; |
||||
} |
||||
|
||||
private: |
||||
const char* const kLabelToName[FieldDescriptor::Label::MAX_LABEL + 1] = { |
||||
"ERROR", // 0 is reserved for errors
|
||||
|
||||
"optional", // LABEL_OPTIONAL
|
||||
"required", // LABEL_REQUIRED
|
||||
"repeated", // LABEL_REPEATED
|
||||
}; |
||||
|
||||
std::unique_ptr<ProtoReflectionDescriptorDatabase> db_; |
||||
std::unique_ptr<DescriptorPool> desc_pool_; |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
int port = 50051; |
||||
if (argc == 2) { |
||||
try { |
||||
port = std::stoi(argv[1]); |
||||
if (port > 65535 || port < 1024) { |
||||
throw std::out_of_range("Port number out of range."); |
||||
} |
||||
} catch (std::invalid_argument&) { |
||||
} catch (std::out_of_range&) { |
||||
} |
||||
} |
||||
|
||||
ReflectionClient reflection_client(grpc::CreateChannel( |
||||
"localhost:" + std::to_string(port), grpc::InsecureChannelCredentials())); |
||||
|
||||
reflection_client.PrintInfo(); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,33 @@ |
||||
#!/bin/bash |
||||
PROTO_DIR="src/proto/grpc/reflection/v1alpha" |
||||
PROTO_FILE="reflection" |
||||
HEADER_DIR="extensions/include/grpc++/impl" |
||||
SRC_DIR="extensions/reflection" |
||||
INCLUDE_DIR="grpc++/impl" |
||||
TMP_DIR="tmp" |
||||
GRPC_PLUGIN="bins/opt/grpc_cpp_plugin" |
||||
PROTOC=protoc |
||||
|
||||
set -e |
||||
|
||||
TMP_DIR=${TMP_DIR}_${PROTO_FILE} |
||||
|
||||
cd $(dirname $0)/../../.. |
||||
|
||||
[ ! -d $HEADER_DIR ] && mkdir -p $HEADER_DIR || : |
||||
[ ! -d $SRC_DIR ] && mkdir -p $SRC_DIR || : |
||||
[ ! -d $TMP_DIR ] && mkdir -p $TMP_DIR || : |
||||
|
||||
$PROTOC -I$PROTO_DIR --cpp_out=$TMP_DIR ${PROTO_DIR}/${PROTO_FILE}.proto |
||||
$PROTOC -I$PROTO_DIR --grpc_out=$TMP_DIR --plugin=protoc-gen-grpc=${GRPC_PLUGIN} ${PROTO_DIR}/${PROTO_FILE}.proto |
||||
|
||||
sed -i "s/\"${PROTO_FILE}.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.pb.cc |
||||
sed -i "s/\"${PROTO_FILE}.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.grpc.pb.cc |
||||
sed -i "s/\"${PROTO_FILE}.grpc.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.grpc.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.grpc.pb.cc |
||||
sed -i "s/\"${PROTO_FILE}.pb.h\"/<${INCLUDE_DIR/\//\\\/}\/${PROTO_FILE}.pb.h>/g" ${TMP_DIR}/${PROTO_FILE}.grpc.pb.h |
||||
|
||||
/bin/mv ${TMP_DIR}/${PROTO_FILE}.pb.h ${HEADER_DIR} |
||||
/bin/mv ${TMP_DIR}/${PROTO_FILE}.grpc.pb.h ${HEADER_DIR} |
||||
/bin/mv ${TMP_DIR}/${PROTO_FILE}.pb.cc ${SRC_DIR} |
||||
/bin/mv ${TMP_DIR}/${PROTO_FILE}.grpc.pb.cc ${SRC_DIR} |
||||
/bin/rm -r $TMP_DIR |
@ -0,0 +1,176 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup Label="ProjectConfigurations"> |
||||
<ProjectConfiguration Include="Debug|Win32"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Debug|x64"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|Win32"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|x64"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
</ItemGroup> |
||||
<PropertyGroup Label="Globals"> |
||||
<ProjectGuid>{5F575402-3F89-5D1A-6910-9DB8BF5D2BAB}</ProjectGuid> |
||||
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||
<PlatformToolset>v100</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||
<PlatformToolset>v110</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||
<PlatformToolset>v120</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||
<PlatformToolset>v140</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||
<ConfigurationType>StaticLibrary</ConfigurationType> |
||||
<UseDebugLibraries>true</UseDebugLibraries> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||
<ConfigurationType>StaticLibrary</ConfigurationType> |
||||
<UseDebugLibraries>false</UseDebugLibraries> |
||||
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||
<ImportGroup Label="ExtensionSettings"> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||
</ImportGroup> |
||||
<PropertyGroup Label="UserMacros" /> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||
<TargetName>grpc++_reflection</TargetName> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||
<TargetName>grpc++_reflection</TargetName> |
||||
</PropertyGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Windows</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Windows</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Windows</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Windows</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemGroup> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\include\grpc++\impl\proto_server_reflection_plugin.h" /> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\include\grpc++\impl\reflection.grpc.pb.h" /> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\include\grpc++\impl\reflection.pb.h" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\reflection\proto_server_reflection.h" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\proto_server_reflection.cc"> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\proto_server_reflection_plugin.cc"> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\reflection.grpc.pb.cc"> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\reflection.pb.cc"> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||
<ImportGroup Label="ExtensionTargets"> |
||||
</ImportGroup> |
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||
<PropertyGroup> |
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||
</PropertyGroup> |
||||
</Target> |
||||
</Project> |
||||
|
@ -0,0 +1,52 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\proto_server_reflection.cc"> |
||||
<Filter>extensions\reflection</Filter> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\proto_server_reflection_plugin.cc"> |
||||
<Filter>extensions\reflection</Filter> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\reflection.grpc.pb.cc"> |
||||
<Filter>extensions\reflection</Filter> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\extensions\reflection\reflection.pb.cc"> |
||||
<Filter>extensions\reflection</Filter> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\include\grpc++\impl\proto_server_reflection_plugin.h"> |
||||
<Filter>extensions\include\grpc++\impl</Filter> |
||||
</ClInclude> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\include\grpc++\impl\reflection.grpc.pb.h"> |
||||
<Filter>extensions\include\grpc++\impl</Filter> |
||||
</ClInclude> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\include\grpc++\impl\reflection.pb.h"> |
||||
<Filter>extensions\include\grpc++\impl</Filter> |
||||
</ClInclude> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClInclude Include="$(SolutionDir)\..\extensions\reflection\proto_server_reflection.h"> |
||||
<Filter>extensions\reflection</Filter> |
||||
</ClInclude> |
||||
</ItemGroup> |
||||
|
||||
<ItemGroup> |
||||
<Filter Include="extensions"> |
||||
<UniqueIdentifier>{8fd45ce8-8f02-367f-e3f7-4c0ae0e36566}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="extensions\include"> |
||||
<UniqueIdentifier>{1a18dfcc-bedf-226e-6929-377aba53249b}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="extensions\include\grpc++"> |
||||
<UniqueIdentifier>{83bf0cce-01da-a93c-0ff3-a1abca63ec5f}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="extensions\include\grpc++\impl"> |
||||
<UniqueIdentifier>{d34e8821-f67b-a793-3419-e2781ab9b3ee}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="extensions\reflection"> |
||||
<UniqueIdentifier>{11feb184-a1d9-5485-26f0-538ddb50deff}</UniqueIdentifier> |
||||
</Filter> |
||||
</ItemGroup> |
||||
</Project> |
||||
|
@ -0,0 +1,206 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" /> |
||||
<ItemGroup Label="ProjectConfigurations"> |
||||
<ProjectConfiguration Include="Debug|Win32"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Debug|x64"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|Win32"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|x64"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>x64</Platform> |
||||
</ProjectConfiguration> |
||||
</ItemGroup> |
||||
<PropertyGroup Label="Globals"> |
||||
<ProjectGuid>{037B9EA1-03CC-6A3B-4E4B-DB17C3D59CF8}</ProjectGuid> |
||||
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||
<PlatformToolset>v100</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||
<PlatformToolset>v110</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||
<PlatformToolset>v120</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||
<PlatformToolset>v140</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>true</UseDebugLibraries> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||
<ConfigurationType>Application</ConfigurationType> |
||||
<UseDebugLibraries>false</UseDebugLibraries> |
||||
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||
<ImportGroup Label="ExtensionSettings"> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\cpptest.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\protobuf.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" /> |
||||
</ImportGroup> |
||||
<PropertyGroup Label="UserMacros" /> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||
<TargetName>reflection_debug_test</TargetName> |
||||
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib> |
||||
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||
<TargetName>reflection_debug_test</TargetName> |
||||
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib> |
||||
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl> |
||||
</PropertyGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||
<ClCompile> |
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<SDLCheck>true</SDLCheck> |
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||
<TreatWarningAsError>true</TreatWarningAsError> |
||||
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||
</ClCompile> |
||||
<Link> |
||||
<SubSystem>Console</SubSystem> |
||||
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
|
||||
<ItemGroup> |
||||
<ClInclude Include="$(SolutionDir)\..\test\cpp\util\proto_reflection_descriptor_database.h" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClCompile Include="$(SolutionDir)\..\test\cpp\util\proto_reflection_descriptor_database.cc"> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\test\cpp\util\reflection_debug\reflection_client.cc"> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc++_reflection\grpc++_reflection.vcxproj"> |
||||
<Project>{5F575402-3F89-5D1A-6910-9DB8BF5D2BAB}</Project> |
||||
</ProjectReference> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc++\grpc++.vcxproj"> |
||||
<Project>{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}</Project> |
||||
</ProjectReference> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj"> |
||||
<Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project> |
||||
</ProjectReference> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="packages.config" /> |
||||
</ItemGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||
<ImportGroup Label="ExtensionTargets"> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||
</ImportGroup> |
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||
<PropertyGroup> |
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||
</PropertyGroup> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" /> |
||||
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" /> |
||||
</Target> |
||||
</Project> |
||||
|
@ -0,0 +1,32 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
||||
<ClCompile Include="$(SolutionDir)\..\test\cpp\util\proto_reflection_descriptor_database.cc"> |
||||
<Filter>test\cpp\util</Filter> |
||||
</ClCompile> |
||||
<ClCompile Include="$(SolutionDir)\..\test\cpp\util\reflection_debug\reflection_client.cc"> |
||||
<Filter>test\cpp\util\reflection_debug</Filter> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClInclude Include="$(SolutionDir)\..\test\cpp\util\proto_reflection_descriptor_database.h"> |
||||
<Filter>test\cpp\util</Filter> |
||||
</ClInclude> |
||||
</ItemGroup> |
||||
|
||||
<ItemGroup> |
||||
<Filter Include="test"> |
||||
<UniqueIdentifier>{fdf7e642-420d-9e18-7a3c-19dca964f218}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\cpp"> |
||||
<UniqueIdentifier>{562b3927-e256-190d-ab72-6b4b04ffb8b2}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\cpp\util"> |
||||
<UniqueIdentifier>{8ed08be4-a27c-d51c-d587-a02cf3dc5abc}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\cpp\util\reflection_debug"> |
||||
<UniqueIdentifier>{b84b1385-e0b2-239b-bac2-81a16bc90249}</UniqueIdentifier> |
||||
</Filter> |
||||
</ItemGroup> |
||||
</Project> |
||||
|
Loading…
Reference in new issue