In the GetList function the client sends a message and the StreamReply returns RowValue and boolean value from a loop one by one. How can I implement it with gRPC stream?
test.proto
service GetList {
rpc Listdata (StreamRequest) returns (stream StreamReply){}
}
message StreamRequest{
string StreamName= 1;
bool boolean= 3;
}
message StreamReply{
string RowValue=1;
bool boolean = 2;
}
The problem lies in my go function. I don't understand how to simply stream values using stream.Send()
server.go
func (s *server) GetList(in *pb.StreamRequest, stream pb.GetList_ListdataServer) error {
strings:= "random strings"
count := 5
for i := 0; i < count; i++ {
if err := stream.Send(strings, true); err != nil {
return err
}
}
return nil
}
question from:
https://stackoverflow.com/questions/65833468/syntax-for-grpc-server-stream 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…