The error handling for unary vs streaming gRPC clients differ significantly. The upshot is if a service returns a *goa.ServiceError from a server-streaming method, the Recv method returns instead a *grpc.StatusError. If I've traced it back correctly, grpc/codegen/service_data.go's streamRecvT and grpc/codegen/client.go's clientEndpointInitT show the difference. From the clientEndpointInitT code I see something like this:
res, err := inv.Invoke(ctx, v)
if err != nil {
resp := goagrpc.DecodeError(err)
switch message := resp.(type) {
case *goapb.ErrorResponse:
return nil, goagrpc.NewServiceError(message)
default:
return nil, goa.Fault(err.Error())
}
}
whereas from the streamRecvT code I see something like this:
v, err := s.stream.Recv()
if err != nil {
return res, err
}
I'm willing to craft a PR for this with a little guidance, or totally willing to leverage someone else's hard work. :) The guidance I would need is mostly whether it's safe and how much of the clientEndpointInitT's error handling can be copied into streamRecvT; the template's data type differ significantly. Assuming this is shared with server-side receive, that deserves additional attention; I've only looked at the client-side.
The error handling for unary vs streaming gRPC clients differ significantly. The upshot is if a service returns a
*goa.ServiceErrorfrom a server-streaming method, the Recv method returns instead a*grpc.StatusError. If I've traced it back correctly, grpc/codegen/service_data.go's streamRecvT and grpc/codegen/client.go's clientEndpointInitT show the difference. From the clientEndpointInitT code I see something like this:whereas from the streamRecvT code I see something like this:
I'm willing to craft a PR for this with a little guidance, or totally willing to leverage someone else's hard work. :) The guidance I would need is mostly whether it's safe and how much of the clientEndpointInitT's error handling can be copied into streamRecvT; the template's data type differ significantly. Assuming this is shared with server-side receive, that deserves additional attention; I've only looked at the client-side.