define proto for gRPC APIs
Description
Define a proto for gRPC API based on existed RESTful APIs.
Hints
Hints for request messages.
- Query params are packed to a request message for each API.
- If an API recieves batch of elements, convert request to a stream.
Hints for reponse messages.
- If an API returns a structure, convert response to a message.
- If an API returns a list, wrap response with a message.
The proto file should be located at protocol/service.proto.
Example
The recommend API coudl be defined as:
service Service {
rpc Recommend(RecommendRequest) returns (RecommendResponse) {}
}
message RecommendRequest {
string user_id = 1;
optional string category = 2;
optional int64 n = 3;
optional int64 offset = 4;
optional string write_back_type = 5;
optional int64 write_back_delay = 6;
}
message RecommendResponse {
repeated string items = 1;
int64 update_time = 2;
}
PS: RecommendResponse can be used in other APIs such as GetLatestItems, GetPopularItems.
I have some experience designing and implementing projects using grpc and may be able to find some time later next month to implement this work.
I have some experience designing and implementing projects using grpc and may be able to find some time later next month to implement this work.
😁Welcome to join our Discord channel to discuss this in the future: https://discord.gg/x6gAtNNkAE