danielgtaylor / danielgtaylor/python-betterproto

ContextManager for stream-unary endpoints

Đang mở
#327 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
1.8k
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách lần theo entry point stream-unary hiện tại của stub được tạo và đường dẫn request bằng async-generator. Xác định interface nhận response và liệu các endpoint stream-stream có được bao gồm hay không; hoàn tất có nghĩa là đã có một context-manager API được tài liệu hóa và thống nhất để ghi request và tiêu thụ response.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
grpc, python
Lĩnh vực
api, backend-api-design
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.