How to compile gRPC Proto files?

84 views Asked by At

How to use the protoc command line program to compile a *.proto file to a certain language for all languages except for Node.

1

There are 1 answers

1
DazWilkin On

protoc uses a plugin model for functionality including the functionality to generate language-specific stubs. protoc includes plugin functionality for several languages (e.g. Python, Java) out-of-the-box but, for others, Go, Rust etc., you'll need to follow additional instructions (e.g. for Go compiling protobufs; Rust has various choices including Prost).

Unless you're a provider wishing to bundle language-specific stubs (as SDKs) alongside your protocol buffers, it's generally better to leave the generation of stubs to end developers. If you still wish to generate the stubs, it may be better to solicit your developers for the languages they need (and generate these stubs) rather than for all languages (the protoc team has a list of languages for which plugins exist but this is likely incomplete).

If you're using gRPC and your protobufs include service and rpc definitions, you will need additional plugins and, in some instances (e.g. Python), to use a different mechanism (Quick Start: Python).