fs2-grpc
fs2-grpc copied to clipboard
Metadata with response
I correctly understand that there is no possibility to send metadata with response?
Yep, I think grpc-java behaves similarily?
Not really. Metadata can only be sent with errors. On a successful response, empty metadata is constructed and sent inside methods.
@Override
public void onError(Throwable t) {
Metadata metadata = Status.trailersFromThrowable(t);
if (metadata == null) {
metadata = new Metadata();
}
call.close(Status.fromThrowable(t), metadata);
aborted = true;
}
@Override
public void onCompleted() {
call.close(Status.OK, new Metadata());
completed = true;
}
And this limitation can be bypassed by returning an error with OK status code. For example:
foo.onError(
StatusProto.toStatusRuntimeException(
Status
.newBuilder()
.setCode(Code.OK.getNumber)
.addDetails(...)
.build()
)
)
How do you feel about trying to make compatible changes to the library? I'm talking about the possibility of implementing a server whose method could return a response with metadata. This would be very useful for being able to place technical information in metadata.
A PR would be nice to see, as long as it is non-breaking and opt-in
@a-khakimov By any chance did you have a working branch or idea of how to add this? 🙏 My team is keen on getting this functionality as well.
add in https://github.com/typelevel/fs2-grpc/pull/713
Fixed in https://github.com/typelevel/fs2-grpc/pull/713