Do not allow NameResolverProvider to choose which is default; make it application-explicit
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 37
Description
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.
Contributor guide
Assessment
This issue has not been assessed yet.