I am a freshman of gRPC, and here is my problem. I'm trying to write a service to expose myOwnService
into a gRPC service per the following service method:
rpc HighFive (stream HighRequest) returns (stream HighReply) {}
The server-side code is as follows:
func (s *server) HighFive(stream pb.Greeter_HighFiveServer) error {
// Oops, don't know how to do here ...
myOwnService(stdin io.ReadCloser, stdout io.WriteCloser)
return nil
}
func myOwnService(stdin io.ReadCloser, stdout io.WriteCloser) error {
// read input from stdin, do something, the write result to stdout
...
return nil
}
As you can see above, I have no idea how to make stream
work with io.Reader
and io.Writer
in my original service, so that the caller of the HighFive
gRPC service can read and write data just like calling myOwnService
normally.
[Update] My current messages are like this, but you can change them if necessary:
message HighRequest {
bytes content = 1;
}
message HighReply {
bytes content = 1;
}