grpc / grpc/grpc-java

Improve usability of multi-valued ASCII keys

Offen
#1,192 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Java
Sterne
12.1k
Forks
4k
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
37

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.