grpc / grpc/grpc-java

Using InternalMetadata class in Armeria

Aperta
#5,788 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
12.1k
Fork
4k
Merge medio
2g 17h
PR unite (30g)
37

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo api/src/main/java/io/grpc/InternalMetadata.java e l’utilizzo di Metadata a cui si fa riferimento in ArmeriaServerCall.java e GrpcService.java. Esamina l’issue di Armeria collegata, la pull request e i thread di discussione per determinare se sia richiesto il supporto al trasporto o una modifica della Metadata API. Il lavoro è completato quando è definita una direzione approvata da un maintainer con un ambito concreto e attuabile.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.