A major advantage to Protobuf (and gRPC) is the ability to generate language bindings reliably and dependably.
The main gRPC site has tutorials for generating clients in many languages:
There is also an expansive ecosystem, so plenty of languages are supported.
In general, there are two main components to generating a language binding:
protoc
: The protobuf compiler which call the language-specific generatorapt
, yum
, brew
, etc)protoc-gen-{language}
: The language-specific generatorRegardless of language, client generation generally follows a pattern of:
$ protoc {includes} {lang-opts} {output-opts} {inputs}
We are primarily concerned with the {includes}
and {inputs}
bits. The rest of the options are up to you.
The .proto
files used as inputs can be found in: cloudvision-apis repo.
You should first clone (or download) that repository. Once you have it, generating a client is as simple as:
$ export CVAPIS=/some/path/to/cloudvision-apis
$ git clone https://github.com/aristanetworks/cloudvision-apis $CVAPIS
$ protoc -I $CVAPIS \
{language-specific options go here} \
$CVAPIS/arista/example.v1/example.proto $CVAPIS/arista/example.v1/services.gen.proto
In the above examples we generate the protobuf bindings (example.proto
) as well as the gRPC services (services.gen.go
)
in the same command. You are free to do them separately, however, different language generators handle this differently.