grpc / grpc/grpc-java

Ability to get callExecutor in ClientInterceptor implementation

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

説明

Various interceptor implementations need to invoke listener callbacks such as in scenarios:
- returning a [FailingClientCall](https://github.com/grpc/grpc-java/blob/v1.35.0/alts/src/main/java/io/grpc/alts/FailingClientCall.java#L34)
- delaying requests and responses
- retrying requests

However, those listener callbacks maybe called in a wrong thread that its user or the channel provider does not intend to use. I believe many interceptor implementations have been doing this. The callbacks should be running in application thread (executed by callExecutor).

`CallOptions` provides `getExecutor()`, but this may return `null`, and in that case the callExecutor should fallback to the channel executor.

In some cases this would not be a big problem, but not in the case of delay, retry, or there are other interceptors switching application thread/running async tasks involved. The problem could be even more difficult to resolve if an interceptor implementation is to be used as a library for others.

Possible solutions:

- In `ManagedChannelImpl`, we add
```java
if (callOptions.getExecutor() == null) { callOptions.withExecutor(channelExecutor); }
```
But if the interceptor uses a different channel, callOptions.getExecutor() may still be null.

- Add a `getExecutor()` method for `Channel` class. Then Interceptor can call `nextChannel.getExecutor()` as a fallback of `callOptions.getExecutor()`.

Problems to some solutions:
- Executor lifecycle.

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

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

調査の方向性

Start by reading CallOptions.getExecutor(), ClientInterceptor implementations, and the proposed ManagedChannelImpl and Channel entry points. Compare the fallback options for obtaining the callExecutor, including executor lifecycle concerns, and define how listener callbacks from delayed, retried, or failing calls should consistently run on the intended executor.

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

評価

技術スタック
grpc, java
領域
api
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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