danielgtaylor / danielgtaylor/python-betterproto
ContextManager for stream-unary endpoints
- Vorherrschende Sprache
- Python
- Sterne
- 1.8k
- Forks
- 234
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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?
Beitragsleitfaden
Rechercherichtung
Start by tracing the generated stub's current stream-unary entry point and its async-generator request path. Resolve the response-receiving interface and whether stream-stream endpoints are included; done means a documented, agreed context-manager API for writing requests and consuming the response.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- grpc, python
- Bereich
- api, backend-api-design
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100