does grpc service must have exactly one input parameter and one return value -
let's have proto file this. can define service this
rpc sayhello () returns (response) {} //service has no input rpc sayhello (request1,request2) returns (response) {}//service has 2 inputs
//.proto file
syntax = "proto3"; service greeter{ rpc sayhello (request) returns (response) {} } message request{ string request = 1; } message response{ string response = 1; }
grpc service methods have 1 input message , 1 output message. typically, these messages used input , output only one method. on purpose, allows adding new parameters later (to messages) while maintaining backward compatibility.
if don't want input or output parameters, can use well-known proto google.protobuf.empty. however, discouraged prevents adding parameters method in future. instead, encouraged follow normal practice of having message request, no contents:
service greeter { rpc sayhello (sayhellorequest) returns (sayhelloresponse) {} } message sayhellorequest {} // service has no input
similarly, if want 2 request parameters, include both in request message:
message sayhellorequest { // service has 2 inputs string request = 1; string anotherrequestparam = 2; }
Comments
Post a Comment