danielgtaylor / danielgtaylor/python-betterproto

Expose request metadata in the generated ```ServiceBase```

Open
#240 9 comments 5 reactions 0 assignees View on GitHub
enhancement medium
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.