danielgtaylor / danielgtaylor/python-betterproto

ContextManager for stream-unary endpoints

Abierto
#327 0 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
1.8k
Forks
234
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.