简体   繁体   中英

Generate client for existing gRPC server

When I have insight into gRPC server code I can see and take the service .proto file and use it to generate (code) the client.

But what about other people's gRPC services? Is there something like wsdl definition that can be used and is provided by the hosted service itself?

Or to reverse the question: How can I allow others to connect to my service? I doubt I have to email people the .proto files.

Protos are the definitions of your gRPC services.

Distributing protos is the gRPC equivalent of sharing eg Swagger docs for REST-based APIs.

You have various options:

  1. Build gRPC-based SDKs for your services (using your protos) and make these available (GitHub, download site etc). Google ( link ) and others do this today for their services. The advantage of this approach is that your users can get started more quickly and|or you may provide higher-level abstractions. The downside is that you are required to keep these current with the protobufs.

  2. Provide the protos (GitHub, website etc.) and let your users build the SDKs for themselves. Google also uses this approach. The advantage is that your users may build SDKs on-demand and in the language(s) that they need.

  3. If your clients require REST, use gRPC gateway and publish your gRPC services using eg Swagger.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM