本文整理汇总了Golang中github.com/coreos/mantle/Godeps/_workspace/src/google/golang.org/grpc/examples/route_guide/proto.RouteGuideClient.RecordRoute方法的典型用法代码示例。如果您正苦于以下问题:Golang RouteGuideClient.RecordRoute方法的具体用法?Golang RouteGuideClient.RecordRoute怎么用?Golang RouteGuideClient.RecordRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/mantle/Godeps/_workspace/src/google/golang.org/grpc/examples/route_guide/proto.RouteGuideClient
的用法示例。
在下文中一共展示了RouteGuideClient.RecordRoute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runRecordRoute
// runRecordRoute sends a sequence of points to server and expects to get a RouteSummary from server.
func runRecordRoute(client pb.RouteGuideClient) {
// Create a random number of random points
r := rand.New(rand.NewSource(time.Now().UnixNano()))
pointCount := int(r.Int31n(100)) + 2 // Traverse at least two points
var points []*pb.Point
for i := 0; i < pointCount; i++ {
points = append(points, randomPoint(r))
}
grpclog.Printf("Traversing %d points.", len(points))
stream, err := client.RecordRoute(context.Background())
if err != nil {
grpclog.Fatalf("%v.RecordRoute(_) = _, %v", client, err)
}
for _, point := range points {
if err := stream.Send(point); err != nil {
grpclog.Fatalf("%v.Send(%v) = %v", stream, point, err)
}
}
reply, err := stream.CloseAndRecv()
if err != nil {
grpclog.Fatalf("%v.CloseAndRecv() got error %v, want %v", stream, err, nil)
}
grpclog.Printf("Route summary: %v", reply)
}