danielgtaylor / danielgtaylor/python-betterproto
Expose request metadata in the generated ```ServiceBase```
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
```protobuf
service Echo {
rpc Echo(EchoRequest) returns (EchoResponse);
// rpc EchoStream(EchoRequest) returns (stream EchoStreamResponse);
}
```
The generated servicer code generates the code but does not expose the request metadata as a parameter.
```python
class EchoService(EchoBase):
async def echo(self, value: str, extra_times: int) -> "EchoResponse":
return value
async def echo_stream(
self, value: str, extra_times: int
) -> AsyncIterator["EchoStreamResponse"]:
for _ in range(extra_times):
yield value
```
The request metadata is really important since it works like headers in rest-api requests, so this is where a client could add authentication tokens, and also where other metadata could be injected by interceptors for instance.
Contributor guide
Assessment
This issue has not been assessed yet.