云容器引擎 CCE-Nginx Ingress对接gRPC协议的后端服务:gRPC服务示例

时间:2024-05-31 08:37:50

gRPC服务示例

在proto文件中定义如下的gRPC服务,客户端可调用helloworld.Greeter服务的SayHello接口。关于gRPC服务示例的源码,请参见gRPC Hello World

syntax = "proto3";
 
option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";
option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
 
package helloworld;
 
// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}
 
// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}
 
// The response message containing the greetings
message HelloReply {
  string message = 1;
}
support.huaweicloud.com/usermanual-cce/cce_10_0855.html