Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

go - Syntax for gRPC-server stream

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...