aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2015-03-05 16:39:25 -0800
committerGravatar Yang Gao <yangg@google.com>2015-03-05 16:39:25 -0800
commit1c40233814db12cca53857241c7314b8ef14ea54 (patch)
treee341e1c18fdcdc38d016c5d37c705885b9c2e26c /include
parentc79a57c3a9ffea6f5a1cbea7b061d204a11281db (diff)
first sets of changes, it builds
Diffstat (limited to 'include')
-rw-r--r--include/grpc++/anonymous_service.h32
-rw-r--r--include/grpc++/anonymous_stub.h11
-rw-r--r--include/grpc++/server.h8
-rw-r--r--include/grpc++/server_builder.h1
-rw-r--r--include/grpc++/server_context.h2
5 files changed, 32 insertions, 22 deletions
diff --git a/include/grpc++/anonymous_service.h b/include/grpc++/anonymous_service.h
index 81b18ea587..456fb8bcb7 100644
--- a/include/grpc++/anonymous_service.h
+++ b/include/grpc++/anonymous_service.h
@@ -31,14 +31,17 @@
*
*/
-#ifndef __GRPCPP_ANONYMOUS_SERVICE_H_
-#define __GRPCPP_ANONYMOUS_SERVICE_H_
+#ifndef GRPCXX_ANONYMOUS_SERVICE_H
+#define GRPCXX_ANONYMOUS_SERVICE_H
+#include <grpc++/byte_buffer.h>
#include <grpc++/stream.h>
+struct grpc_server;
+
namespace grpc {
-typedef ServerReaderWriter<ByteBuffer, ByteBuffer> GenericServerReaderWriter;
+typedef ServerAsyncReaderWriter<ByteBuffer, ByteBuffer> GenericServerReaderWriter;
class AnonymousServerContext : public ServerContext {
public:
@@ -50,23 +53,20 @@ class AnonymousServerContext : public ServerContext {
grpc::string host_;
};
-// Anonymous stubs provide a type-unsafe interface to call gRPC methods
-// by name.
class AnonymousService {
public:
- explicit AnonymousService(CompletionQueue* cq) : cq_(cq) {}
-
- struct CallDetails {
- grpc::string method;
- grpc::string host;
- };
-
- void RequestCall(AnonymousServerContext* ctx, GenericServerReaderWriter* reader_writer, CompletionQueue* cq, void* tag);
+ // TODO(yangg) Once we can add multiple completion queues to the server
+ // in c core, add a CompletionQueue* argument to the ctor here.
+ AnonymousService() : server_(nullptr) {}
+ void RequestCall(AnonymousServerContext* ctx,
+ GenericServerReaderWriter* reader_writer,
+ CompletionQueue* cq, void* tag);
private:
- CompletionQueue* const cq_;
+ friend class Server;
+ Server* server_;
};
-} // namespace
+} // namespace grpc
-#endif
+#endif // GRPCXX_ANONYMOUS_SERVICE_H
diff --git a/include/grpc++/anonymous_stub.h b/include/grpc++/anonymous_stub.h
index 4a7543c760..ccb474e21b 100644
--- a/include/grpc++/anonymous_stub.h
+++ b/include/grpc++/anonymous_stub.h
@@ -31,14 +31,15 @@
*
*/
-#ifndef __GRPCPP_ANONYMOUS_STUB_H_
-#define __GRPCPP_ANONYMOUS_STUB_H_
+#ifndef GRPCXX_ANONYMOUS_STUB_H
+#define GRPCXX_ANONYMOUS_STUB_H
+#include <grpc++/byte_buffer.h>
#include <grpc++/stream.h>
namespace grpc {
-typedef ClientReaderWriter<ByteBuffer, ByteBuffer> GenericClientReaderWriter;
+typedef ClientAsyncReaderWriter<ByteBuffer, ByteBuffer> GenericClientReaderWriter;
// Anonymous stubs provide a type-unsafe interface to call gRPC methods
// by name.
@@ -53,6 +54,6 @@ class AnonymousStub {
std::shared_ptr<ChannelInterface> channel_;
};
-} // namespace
+} // namespace grpc
-#endif
+#endif // GRPCXX_ANONYMOUS_STUB_H
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index e3ba93e487..7e8f6d48b5 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -48,6 +48,8 @@
struct grpc_server;
namespace grpc {
+class AnonymousServerContext;
+class AnonymousService;
class AsynchronousService;
class RpcService;
class RpcServiceMethod;
@@ -69,6 +71,7 @@ class Server GRPC_FINAL : private CallHook,
void Wait();
private:
+ friend class AnonymousService;
friend class ServerBuilder;
class SyncRequest;
@@ -82,6 +85,7 @@ class Server GRPC_FINAL : private CallHook,
// The service must exist for the lifetime of the Server instance.
bool RegisterService(RpcService* service);
bool RegisterAsyncService(AsynchronousService* service);
+ void RegisterAnonymousService(AnonymousService* service);
// Add a listening port. Can be called multiple times.
int AddPort(const grpc::string& addr);
// Start the server.
@@ -99,6 +103,10 @@ class Server GRPC_FINAL : private CallHook,
ServerAsyncStreamingInterface* stream,
CompletionQueue* cq, void* tag);
+ void RequestAsyncAnonymousCall(AnonymousServerContext* context,
+ ServerAsyncStreamingInterface* stream,
+ CompletionQueue* cq, void* tag);
+
// Completion queue.
CompletionQueue cq_;
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index 60c891ce81..514a6687dc 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -87,6 +87,7 @@ class ServerBuilder {
std::vector<AsynchronousService*> async_services_;
std::vector<grpc::string> ports_;
std::shared_ptr<ServerCredentials> creds_;
+ AnonymousService* anonymous_service_;
ThreadPoolInterface* thread_pool_;
};
diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h
index a986fff46b..9e3b80c641 100644
--- a/include/grpc++/server_context.h
+++ b/include/grpc++/server_context.h
@@ -66,7 +66,7 @@ class CompletionQueue;
class Server;
// Interface of server side rpc context.
-class ServerContext GRPC_FINAL {
+class ServerContext {
public:
ServerContext(); // for async calls
~ServerContext();