grpc / grpc/grpc-java

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

オープン
#7,917 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Java
スター
12.1k
フォーク
4k
平均マージ
2日 17時間
マージ済み PR(30日)
37

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず api/src/main/java/io/grpc/NameResolverRegistry.java と core/src/main/java/io/grpc/internal/ManagedChannelImpl.java を読み、次に "foo.googleapis.com:8080" のようなエンドポイントに対してプロバイダーがどのように順序付けされ、選択されるかを追跡します。完了時には、デフォルトプロバイダーの選択をアプリケーションにとって明示的なものにし、サードパーティのクラス名の順序付けに依存せずに URI の処理を明確にできるようにします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
backend-api-design, networking
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。