vyshane/grpc-swift-combine

Expose trailingMetadata

Closed this issue · 7 comments

Support for GRPCStatusAndMetadata - https://github.com/grpc/grpc-swift/blob/main/Sources/GRPC/GRPCStatusAndMetadata.swift would be awesome.

Currently on GRPCStatus is exposed - https://github.com/vyshane/grpc-swift-combine/blob/master/Sources/CombineGRPC/Client/GRPCExecutor.swift#L93

Do you need access to the trailing metadata only on failure, or do you also need it on success?

On error @vyshane — The Go backend adds additional error details when an error occurs - I’m trying do get them using the method described here - grpc/grpc-swift#759 (comment)

Okay, if we're only talking about supporting trailing metadata for the error use case, then the call APIs can be changed to:

RPC Style Input and Output Types
Unary Request -> AnyPublisher<Response, GRPCError>
Server streaming Request -> AnyPublisher<Response, GRPCError>
Client streaming AnyPublisher<Request, Error> -> AnyPublisher<Response, GRPCError>
Bidirectional streaming AnyPublisher<Request, Error> -> AnyPublisher<Response, GRPCError>

Where the new GRPCError type is a struct with status and trailingMetadata fields. We can't use the upstream GRPCStatusAndMetadata type because it does not extend Error.

This will be a major breaking change for all call methods.

Cool - this would make the library even more transparent 😉 - looking forward to this addition

I have just merged a PR that adds trailing metadata support to client calls and server handlers. I called the wrapper type RPCError. Swift gRPC already has a type called GRPCError. Can you give master branch a go and let me know if that works for your use case?

This introduced breaking API changes for call and handle functions, as well as RetryPolicy.

I have just released a new version, v0.18.0, that has support for trailing metadata on error.