【发布时间】:2018-06-24 18:25:22
【问题描述】:
我想了解 Go 中的 gRPC 服务和 Python 中的客户端的兼容性。
例如if the service is implemented in Go,它会有这样的签名:
...
func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) {
...
}
...
func (s *routeGuideServer) ListFeatures(rect *pb.Rectangle, stream pb.RouteGuide_ListFeaturesServer) error {
...
}
...
func (s *routeGuideServer) RecordRoute(stream pb.RouteGuide_RecordRouteServer) error {
...
}
...
func (s *routeGuideServer) RouteChat(stream pb.RouteGuide_RouteChatServer) error {
...
}
注意error 对象的返回方式。
现在,如果我必须implement the client in Python it will be something like this:
feature = stub.GetFeature(point)
for received_route_note in stub.RouteChat(sent_route_note_iterator):
Go 服务实现返回的 error 字段会发生什么情况?如果服务器端出现错误,Python客户端如何处理?
【问题讨论】: