'Grpc server with async and sync services at the same time

I need to be able to serve responses for some particular requests from the main thread, while the rest can arrive from any thread. With that in mind, I created a GRPC server which has 2 services, one is implemented as an AsyncService, and the other as a sync service.

However, when adding a completion queue, the sync service no longer responds to requests.

    builder.RegisterService(this); // this inherits from Service (sync)
    builder.RegisterService(&m_service); // m_services is an AsyncService 
    m_mainThreadQueue = builder.AddCompletionQueue();
    m_server = std::unique_ptr<Server>(builder.BuildAndStart());
    {
        (new GrabSnapshotCallData(this, &m_service, m_mainThreadQueue.get()))->Proceed();
    }
    m_server->Wait();

Adding the completion queue makes the sync service no longer response to requests. I couldn't find much information about this particular topic anywhere, so perhaps it is not really supported in grpc.

So, is there a way to have both async and sync services simultaneously on the same server? If not, what should I do to emulate that behavior



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source