danielgtaylor / danielgtaylor/python-betterproto

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

Aperta
#240 9 commenti 5 reazioni 0 assegnatari Vedi su GitHub
enhancement medium
Lingua principale
Python
Stelle
1.8k
Fork
234
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

```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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.