grpc / grpc/grpc-java

Using InternalMetadata class in Armeria

Open
#5,788 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.1k
Forks
4k
Avg merge
2d 17h
Merged PRs (30d)
37

Description

Hi all.

As some of you may have seen, [Armeria](https://line.github.io/armeria/) team mantains a Java [implementation](https://github.com/line/armeria/tree/master/grpc) of gRPC that runs on top of the Armeria server framework, a generic HTTP/1+2 server framework built on Netty (made by our good friend @trustin himself :) )

We interface with protoc stubs by creating `Call` objects and starting them - after started, a `Call` goes through `io.grpc` business logic as normal in most cases with surprisingly few gotchas. The `Call` interface is a quite nice plugin point.

https://github.com/line/armeria/blob/master/grpc/src/main/java/com/linecorp/armeria/server/grpc/ArmeriaServerCall.java

We have one major caveat though, no support for the `Metadata` class

https://github.com/line/armeria/blob/master/grpc/src/main/java/com/linecorp/armeria/server/grpc/GrpcService.java#L77

While Armeria has its own methods for adding response trailers, we're finding more and more users would like to be able to use it so their existing gRPC business logic can run as-is on Armeria, and if possible I'd like to achieve that. It means I need to use [InternalMetadata](https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/InternalMetadata.java) to be able to create and serialize `Metadata`.

Is it kosher for Armeria to use this class? I understand it is for "specifically supported transport packages" - if Armeria could be considered a specifically supported transport package, that would be great! But if it's not possible to have official support like that, if it's "at your own risk but should be ok" that'd be fine too. For context, the first version of our implementation used a lot of `io.grpc.internal` classes to try to minimize code duplication - that was naturally a nightmare to maintain and I'm hoping not to repeat my mistake ;)

Also, as an alternative or in addition, any thoughts on making `Metadata` an interface and letting implementations control the serialization themselves? If that happened, we wouldn't need to use `InternalMetadata` either.

Thanks!

References
- One of several slack [threads](https://line-armeria.slack.com/archives/C1NGPBUH2/p1558419766016800)
- https://github.com/line/armeria/issues/1788
- https://github.com/line/armeria/pull/1790

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.