我正在查看grpc示例,但我不理解该示例。有人可以向我解释吗?
示例位于: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})
}
}
有人可以解释一下执行的过程吗,怎么称呼它?谢谢。
答案 0 :(得分:1)
客户端调用方法
?>
<style type="text/css">
.img_div > img {
height: 100px;
width: 100px;
}
</style>
<?php
$sql = "SELECT * FROM items WHERE category LIKE '%$search%'";
$result = mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($result)) {
echo "<div class='img_div'>";
echo "<img src='img/".$row['image']."'>";
echo "<p>" . $row['description']."</p>";
echo "<p>" . $row['category']."</p>";
echo "</div>";
}
因此服务器将开始呼叫 stream, err := c.BidirectionalStreamingEcho(ctx)