grpc / grpc/grpc-java

Improve usability of multi-valued ASCII keys

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

Descrizione

For keys like Grpc-Accept-Encoding ["gzip", "deflate"] is semantically equivalent to ["gzip,deflate"]. We should have a utility or tweak our API to make encourage applications to handle multi-valued metadata correctly.

A separate but related issue is that users of Keys have to be aware of whether the key is for ascii or binary, since you are likely to use the get() methods differently between the two. It might be good to have some "meta" key that could behave identically between the two.

For example, we could have something like:

``` java
public interface MultivalueMarshaller {
List splitValues(C combined);
C combineValues(List separate);
}
```

Which could be used as a special key:

```
new Metadata.Key.of("Grpc-Accept-Encoding", new MultivalueAcceptEncoding(), new AcceptEncodingMarshaller());
```

The key would always act as if there was only one value, and would typically be used with `Metadata.get()`.

I'm not 100% sold on the example solution, because it seems we keep adding more and more layers.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.