BlockingStub returns iterator that cannot be closed
- 主要言語
- Java
- スター
- 12.1k
- フォーク
- 4k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 37
説明
I use a blocking sub for a method that returns a stream of messages. The return type of it is `Iterator`. It turns out I cannot make grpc client to end the request (e.g. because of client failure). There are a number of cases where an open connection may stuck in client because of that
The implementation uses
`io.grpc.stub.ClientCalls#blockingServerStreamingCall(io.grpc.Channel, io.grpc.MethodDescriptor, io.grpc.CallOptions, ReqT)`
call, which in turn uses `BlockingResponseStream`. There is no way to reach the `io.grpc.ClientCall#cancel` method form the Iterator. Could be nice to wrap an Iterator or make it implement an interface in the similar way as done with ServerStreamObserver/ClientStreamObserver
The other approach could be to implement `AutoCloseable` from Java with this iterator
There is also a comment on the Iterator implementation class
```
// TODO(ejona86): determine how to allow ClientCall.cancel() in case of application error.
```
コントリビューションガイド
調査の方向性
io.grpc.stub.ClientCalls#blockingServerStreamingCall と BlockingResponseStream の実装から始め、アプリケーションエラー時に ClientCall.cancel() を許可することについての TODO を読んでください。提案されている Iterator ラッパー、interface、AutoCloseable のアプローチを比較してください。既存の Iterator の動作を壊さずに、blocking streaming の結果からリクエストのキャンセルを公開できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- api
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100