aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-08-13 15:30:01 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-08-13 15:30:01 -0700
commit8c0389d84e2df505d5fee065180a73e20f9db98f (patch)
tree4ca1c33b7872563a415e989071b64d9e4429df22 /include/grpc++
parentd9c1bc7281cac61472ba2cd6d39c1d5b878cc3bc (diff)
parent523201cee080457cb1386f729c2af4cff1477c92 (diff)
Merge pull request #2921 from yang-g/unknown_service
Use a sync service to handle requests to unknown services
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/completion_queue.h2
-rw-r--r--include/grpc++/impl/rpc_service_method.h15
-rw-r--r--include/grpc++/server.h2
-rw-r--r--include/grpc++/server_context.h2
4 files changed, 21 insertions, 0 deletions
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h
index 0523ab6a0e..2f30211145 100644
--- a/include/grpc++/completion_queue.h
+++ b/include/grpc++/completion_queue.h
@@ -63,6 +63,7 @@ template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
class BidiStreamingHandler;
+class UnknownMethodHandler;
class ChannelInterface;
class ClientContext;
@@ -138,6 +139,7 @@ class CompletionQueue : public GrpcLibrary {
friend class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
friend class BidiStreamingHandler;
+ friend class UnknownMethodHandler;
friend class ::grpc::Server;
friend class ::grpc::ServerContext;
template <class InputMessage, class OutputMessage>
diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h
index 3cfbef7806..925801e1ce 100644
--- a/include/grpc++/impl/rpc_service_method.h
+++ b/include/grpc++/impl/rpc_service_method.h
@@ -208,6 +208,21 @@ class BidiStreamingHandler : public MethodHandler {
ServiceType* service_;
};
+// Handle unknown method by returning UNIMPLEMENTED error.
+class UnknownMethodHandler : public MethodHandler {
+ public:
+ void RunHandler(const HandlerParameter& param) GRPC_FINAL {
+ Status status(StatusCode::UNIMPLEMENTED, "");
+ CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops;
+ if (!param.server_context->sent_initial_metadata_) {
+ ops.SendInitialMetadata(param.server_context->initial_metadata_);
+ }
+ ops.ServerSendStatus(param.server_context->trailing_metadata_, status);
+ param.call->PerformOps(&ops);
+ param.call->cq()->Pluck(&ops);
+ }
+};
+
// Server side rpc method class
class RpcServiceMethod : public RpcMethod {
public:
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index 94ee0b6a4a..8755b4b445 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -228,6 +228,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook {
grpc::condition_variable callback_cv_;
std::list<SyncRequest>* sync_methods_;
+ std::unique_ptr<RpcServiceMethod> unknown_method_;
+ bool has_generic_service_;
// Pointer to the c grpc server.
grpc_server* const server_;
diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h
index 4f7fc54ef1..8262dee654 100644
--- a/include/grpc++/server_context.h
+++ b/include/grpc++/server_context.h
@@ -73,6 +73,7 @@ template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
class BidiStreamingHandler;
+class UnknownMethodHandler;
class Call;
class CallOpBuffer;
@@ -159,6 +160,7 @@ class ServerContext {
friend class ServerStreamingHandler;
template <class ServiceType, class RequestType, class ResponseType>
friend class BidiStreamingHandler;
+ friend class UnknownMethodHandler;
friend class ::grpc::ClientContext;
// Prevent copying.