Reputation: 319
I am looking at the grpc example, but I don't understand this example. Can someone explain it to me?
the example located: https://github.com/grpc/grpc-go/blob/master/examples/features/cancellation/server/main.go#L52
func (s *server) BidirectionalStreamingEcho(stream pb.Echo_BidirectionalStreamingEchoServer) error {
for {
in, err := stream.Recv()
if err != nil {
fmt.Printf("server: error receiving from stream: %v\n", err)
if err == io.EOF {
return nil
}
return err
}
fmt.Printf("echoing message %q\n", in.Message)
stream.Send(&pb.EchoResponse{Message: in.Message})
}
}
Can someone explain the process of this execution, how is it called? thx.
Upvotes: 1
Views: 763
Reputation: 319
the client call the method
stream, err := c.BidirectionalStreamingEcho(ctx)
so server will start the call BidirectionalStreamingEcho
Upvotes: 1