Async RPC methods in protobuf?

1,691 views
Skip to first unread message

song...@hotmail.com

unread,
Nov 15, 2016, 7:26:15 PM11/15/16
to Protocol Buffers
I notice that when RPC methods are defined in a proto file, they are all sync APIs. Is there a way to define async methods? Thanks.

Feng Xiao

unread,
Nov 15, 2016, 7:30:12 PM11/15/16
to song...@hotmail.com, Protocol Buffers
Are you using grpc? You can post grpc related questions to https://groups.google.com/forum/#!forum/grpc-io

On Tue, Nov 15, 2016 at 4:03 PM, <song...@hotmail.com> wrote:
I notice that when RPC methods are defined in a proto file, they are all sync APIs. Is there a way to define async methods? Thanks.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

song...@hotmail.com

unread,
Nov 15, 2016, 7:37:28 PM11/15/16
to Protocol Buffers, song...@hotmail.com
Thanks for the reply. I am not using gRPC. I want to use protobuf to define RPC, but have a separate or customized transport implementation.


On Tuesday, November 15, 2016 at 4:30:12 PM UTC-8, Feng Xiao wrote:
Are you using grpc? You can post grpc related questions to https://groups.google.com/forum/#!forum/grpc-io
On Tue, Nov 15, 2016 at 4:03 PM, <song...@hotmail.com> wrote:
I notice that when RPC methods are defined in a proto file, they are all sync APIs. Is there a way to define async methods? Thanks.

--
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.

Feng Xiao

unread,
Nov 15, 2016, 8:11:36 PM11/15/16
to song...@hotmail.com, Protocol Buffers
On Tue, Nov 15, 2016 at 4:37 PM, <song...@hotmail.com> wrote:
Thanks for the reply. I am not using gRPC. I want to use protobuf to define RPC, but have a separate or customized transport implementation.
There is no such thing as sync vs. async API in proto definition. It's only relevant in the generated service API. For example, given:
service HelloService {
  rpc Hello(Request) returns (Response);
}
 
You can generate code that provides sync API, or generate code that provides async API:
class HelloService {
 public:
  void Hello(const Request& request, const std::function<void(const Response&)>& result_callback);
}



On Tuesday, November 15, 2016 at 4:30:12 PM UTC-8, Feng Xiao wrote:
Are you using grpc? You can post grpc related questions to https://groups.google.com/forum/#!forum/grpc-io

On Tue, Nov 15, 2016 at 4:03 PM, <song...@hotmail.com> wrote:
I notice that when RPC methods are defined in a proto file, they are all sync APIs. Is there a way to define async methods? Thanks.

--
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 post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.

song...@hotmail.com

unread,
Nov 15, 2016, 8:17:56 PM11/15/16
to Protocol Buffers, song...@hotmail.com
Yes, I agree with you that it is all dependent on the generated code. So does protobuf compiler provide the option to generate async APIs? If not, how complicated will it be to modify the complier?

Feng Xiao

unread,
Nov 15, 2016, 8:43:13 PM11/15/16
to song...@hotmail.com, Protocol Buffers
On Tue, Nov 15, 2016 at 5:17 PM, <song...@hotmail.com> wrote:
Yes, I agree with you that it is all dependent on the generated code. So does protobuf compiler provide the option to generate async APIs? If not, how complicated will it be to modify the complier?
Protobuf itself doesn't provide the RPC implementation. You can write a protoc plugin to generate RPC code just like how most protobuf-based RPC works:
 
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages