protoc generated c++ files

53 views
Skip to first unread message

Paul Lemay

unread,
May 6, 2020, 7:52:51 PM5/6/20
to Protocol Buffers
Hello,

I have this proto files where the root file is defined as below:

syntax = "proto3";

package upfservice.v1;

import "session.proto";
import "hello.proto";

// The Upfu_BfRuntime service definition.
service UPFService {
// Initial handshake initiated by client.
rpc Hello(stream HelloRequest) returns (stream HelloResponse) {}

// Client shutdown (resource can be cleaned up)
rpc Bye(ByeRequest) returns (ByeResponse) {}

// Ping request
rpc Ping(PingRequest) returns (PingResponse) {}

// Session management bi-directional streaming api.
rpc Session(stream ServiceDataSessionRequest) returns (stream ServiceDataSessionResponse) {}

// UR collection server streaming (client call this one then wait for continuous UR stream)
rpc UsageReport(UsageReportRequest) returns (stream UsageReports) {}
}

The generated file gives me a typedef to work with:


typedef WithAsyncMethod_Hello<WithAsyncMethod_Bye<WithAsyncMethod_Ping<WithAsyncMethod_Session<WithAsyncMethod_UsageReport<Service > > > > > AsyncService;

It does not seems right since I can't use the AsyncService to do anything. Is it because there is a limit of 1 asynchronous stream rpc per service?



Derek Perez

unread,
May 6, 2020, 9:01:00 PM5/6/20
to Paul Lemay, Protocol Buffers
Are you generating the C++ code with the proper grpc plugin as well? Services won't generate useful stubs without that.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/a3941835-afcf-4a60-92fb-844a59837708%40googlegroups.com.

Derek Perez

unread,
May 6, 2020, 9:02:31 PM5/6/20
to Paul Lemay, Protocol Buffers
Here's a link to the docs for the protoc grpc plugin: 

Paul Lemay

unread,
May 7, 2020, 6:53:09 AM5/7/20
to Protocol Buffers
Hello Derek,

thanks for your help. 

Yes, the procedure to compile is right. If I keep only 1 async rpc stream (i.e., say rpc Session), and I recompile, I get the typedef that I am expecting:
typedef WithAsyncMethod_Session<Service > AsyncService;

Even if there is multiple async rpc stream there is only 1 typedef produced where I would expect many. This lead me to believe that the service must be arrange to handle a single async rpc stream or that our proto files are are defined properly. Here is the main that includes the other:
syntax = "proto3";

package upfservice.v1;

import "session.proto";
import "hello.proto";

// The Upfu_BfRuntime service definition.
service UPFService {
// Initial handshake initiated by client.
rpc Hello(stream HelloRequest) returns (stream HelloResponse) {}

// Client shutdown (resource can be cleaned up)
rpc Bye(ByeRequest) returns (ByeResponse) {}

// Ping request
rpc Ping(PingRequest) returns (PingResponse) {}

// Session management bi-directional streaming api.
rpc Session(stream ServiceDataSessionRequest) returns (stream ServiceDataSessionResponse) {}

// UR collection server streaming (client call this one then wait for continuous UR stream)
rpc UsageReport(UsageReportRequest) returns (stream UsageReports) {}
}



What typedef sould I expect out of there?


To unsubscribe from this group and stop receiving emails from it, send an email to prot...@googlegroups.com.

Paul Lemay

unread,
May 8, 2020, 6:21:20 AM5/8/20
to Protocol Buffers
Finally,

The typedef template above was generated properly and I was mislead by the template error message that was raised at compiled time. When invoking the Request session, the stream parameter passed was wrong.

mCallData->GetService()->RequestSession(&mCtx, &mStream,
mCallData->GetCompletionQueue(),
mCallData->GetCompletionQueue(), &mProceedFunction);

I mismatched request and response in the ServerAsyncReaderWriter declaration:

grpc::ServerAsyncReaderWriter<Response, Request> mStream

So to the question I was asking, yes, it is possible to have multiple rpc streams in a single grpc service.

Reply all
Reply to author
Forward
0 new messages