Skip to content
Snippets Groups Projects
Commit 1ad253d1 authored by Yang Gao's avatar Yang Gao
Browse files

expose the server's cq through the generic service object

parent 5333c5a2
No related branches found
No related tags found
No related merge requests found
......@@ -59,12 +59,16 @@ class AsyncGenericService GRPC_FINAL {
public:
// TODO(yangg) Once we can add multiple completion queues to the server
// in c core, add a CompletionQueue* argument to the ctor here.
AsyncGenericService() : server_(nullptr) {}
// TODO(yangg) support methods list.
AsyncGenericService(const grpc::string& methods) : server_(nullptr) {}
void RequestCall(GenericServerContext* ctx,
GenericServerAsyncReaderWriter* reader_writer,
CompletionQueue* cq, void* tag);
// The new rpc event should be obtained from this completion queue.
CompletionQueue* completion_queue();
private:
friend class Server;
Server* server_;
......
......@@ -70,8 +70,6 @@ class Server GRPC_FINAL : private CallHook,
// function to ever return)
void Wait();
CompletionQueue* cq() { return &cq_; }
private:
friend class AsyncGenericService;
friend class ServerBuilder;
......
......@@ -43,5 +43,9 @@ void AsyncGenericService::RequestCall(
server_->RequestAsyncGenericCall(ctx, reader_writer, cq, tag);
}
CompletionQueue* AsyncGenericService::completion_queue() {
return &server_->cq_;
}
} // namespace grpc
......@@ -211,7 +211,7 @@ bool Server::RegisterService(RpcService* service) {
bool Server::RegisterAsyncService(AsynchronousService* service) {
GPR_ASSERT(service->dispatch_impl_ == nullptr &&
"Can only register one asynchronous service against one server.");
"Can only register an asynchronous service against one server.");
service->dispatch_impl_ = this;
service->request_args_ = new void* [service->method_count_];
for (size_t i = 0; i < service->method_count_; ++i) {
......@@ -230,7 +230,7 @@ bool Server::RegisterAsyncService(AsynchronousService* service) {
void Server::RegisterAsyncGenericService(AsyncGenericService* service) {
GPR_ASSERT(service->server_ == nullptr &&
"Can only register one generic service against one server.");
"Can only register an async generic service against one server.");
service->server_ = this;
}
......
......@@ -91,7 +91,7 @@ bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message) {
class GenericEnd2endTest : public ::testing::Test {
protected:
GenericEnd2endTest() {}
GenericEnd2endTest() : generic_service_("*") {}
void SetUp() GRPC_OVERRIDE {
int port = grpc_pick_unused_port_or_die();
......@@ -145,7 +145,7 @@ class GenericEnd2endTest : public ::testing::Test {
generic_service_.RequestCall(&srv_ctx, &stream, &srv_cq_, tag(2));
verify_ok(server_->cq(), 2, true);
verify_ok(generic_service_.completion_queue(), 2, true);
EXPECT_EQ(server_address_.str(), srv_ctx.host());
EXPECT_EQ("/grpc.cpp.test.util.TestService/Echo", srv_ctx.method());
ByteBuffer recv_buffer;
......@@ -212,7 +212,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
generic_service_.RequestCall(&srv_ctx, &srv_stream, &srv_cq_, tag(2));
verify_ok(server_->cq(), 2, true);
verify_ok(generic_service_.completion_queue(), 2, true);
EXPECT_EQ(server_address_.str(), srv_ctx.host());
EXPECT_EQ("/grpc.cpp.test.util.TestService/BidiStream", srv_ctx.method());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment