danielgtaylor / danielgtaylor/python-betterproto
ContextManager for stream-unary endpoints
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 234
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
It would be nice if we could interact with a stream-unary endpoint by using a context-manager.
currently the only way to send messages to a stream-unary endpoint is by using an async-generator:
```python
async def request_iterator():
yield create_some_request()
yield create_some_request()
channel = Channel(host="localhost", port=1234)
stub = MyStub(channel)
response = await stub.my_endpoint(request_iterator())
```
what i imagine is something like this:
```python
channel = Channel(host="localhost", port=1234)
stub = MyStub(channel)
async with stub.my_endpoint as stream:
stream.write(create_some_request())
stream.write(create_some_request())
```
Open questions:
- how should the interface for receiving the response look?
- could this be used for stream-stream endpoints as well?
コントリビューションガイド
調査の方向性
生成されたスタブの現在の stream-unary エントリポイントと、async-generator によるリクエストパスを追跡することから始めます。レスポンスを受け取るインターフェースと、stream-stream エンドポイントが含まれるかどうかを確認します。完了条件は、リクエストを書き込み、レスポンスを消費するための、文書化され合意された context-manager API が定まっていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- grpc, python
- 領域
- api, backend-api-design
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100