service without gRPC

518 views
Skip to first unread message

Mohamed Koubaa

unread,
Aug 5, 2016, 11:03:47 AM8/5/16
to Protocol Buffers
Hello,

As per the language guide, defining a service in a .proto file will generate RPC stubs which we can implement (or let gRPC implement). https://developers.google.com/protocol-buffers/docs/proto3#services

We have a zeroMQ service that we are interested in migrating from JSON-RPC to gRPC.  To stage this effort, we are interesting in creating the RPC stubs and using the same zeroMQ to implement them, and then move to gRPC once we deal with an orthogonal service discovery problem that prevents us from dropping zeroMQ immediately.

To my surprise, adding the RPC code to the .proto did not generate any stubs in c++. I am using proto3 beta4 at the moment.  Do I need any additional flags to protoc?

Thanks
Mohamed Koubaa
Software Developer
ANSYS Inc

Paul Johnston

unread,
Aug 5, 2016, 11:22:49 AM8/5/16
to Protocol Buffers
You need to invoke the grpc plugin.  The default protoc tool does not generate gRPC stubs on it's own.  Here's what it looks like:

$ protoc --cpp_out=outdir \

  --plugin=protoc-gen-grpc=path/to/the/grpc-cpp-plugin \

  --grpc_out=outdir \

  path/to/your/helloworld.proto


# Generated by protoc

helloworld.pb.h

helloworld.pb.cc

# Generated by grpc plugin

helloworld.grpc.pb.h

helloworld.grpc.pb.cc


I've written a tool for bazel that can do this for you and provide all the required build environment, if you're interested in trying it out.


HTH,
Paul

John Obaterspok

unread,
Aug 6, 2016, 3:20:39 AM8/6/16
to Mohamed Koubaa, Protocol Buffers
Hi,

for using protobuf (ver 2) over zeromq. Perhaps that could ease your migration to gRPC.

-- john

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

Mohamed Koubaa

unread,
Aug 8, 2016, 9:24:45 AM8/8/16
to John Obaterspok, Protocol Buffers
Thanks for the replies.  The documentation has room for improvement on this.  I just noticed this:

option cc_generic_services = true;

It seems to generate these stubs without the grpc plugin.  However, it did not seem to work for C# or Python (it seems the gRPC plugin is the only way to make those stubs).

I did notice the rpcz project but did not have a chance yet to evaluate it.

Thanks,
Mohamed Koubaa
Software Developer
ANSYS Inc 
Reply all
Reply to author
Forward
0 new messages