grpc / grpc/grpc-java

Do not allow NameResolverProvider to choose which is default; make it application-explicit

Aperta
#7,917 3 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

I find ordering of NameResolverProviders loaded by GRPC is up to the priority and classname. Comments in [NameResolverRegistry](https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/NameResolverRegistry.java) indicate that GRPC needs to make the ordering stable because it relies on the first one as default.

But, I wonder why does it take use of classname for ordering? The classname of NameResolverProvider from third-party library is out of control of developers and it will cause some problem.

Moreover, comments in [ManagedChannelImpl](https://github.com/grpc/grpc-java/blob/master/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java) indicate that it expects to use DnsNameResolverProvider as default for compatibility with some googleapis endpoint like "foo.googleapis.com:8080". But in fact it use the first NameResolverProvider as default.
If some third-party library offers a NameResolverProvider with a package name greater than "io.grpc", which uses the same priority as DnsNameResolverProvider and also supports the same format like "foo.googleapis.com:8080", this hard-coded compatibility in ManagedChannelImpl will be broken. And it's hard for developers to solve this by doing some config thing.

Here's an example:
* We use google-cloud-firestore library to integrate firestore service. The hard-coded endpoint is "firestore.googleapis.com:443", which seems to be the case handled by the compatibility of ManagedChannelImpl.
* We also use another opensource library to extend grpc functionalities. This library offers a StaticNameResolverProvider with priortiy=5, same as DnsNameResolverProvider, and the package name is greater than "io.grpc". It also supports URI in format like "firestore.googleapis.com:443".
* When grpc wants to find a NameResolverProvider for firestore endpoint, it will find StaticNameResolverProvider instead of DnsNameResolverProvider.

Since grpc is kind of basis library and offers extension functionality for NameResolverProvider, I think it should make both of URI format and ordering of NameResolverProviders more clear. Besides, GRPC should also offer a more specific way to set the default NameResolverProvider.

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.