Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Propagating gRPC context in Python

There are two python gRPC services A and B.
Service A needs to call a rpc on service B in order to send a response to the client.
Service A also has an interceptor that adds information to gRPC contexts it uses.

Question:
How can I pass the gRPC context to service B so I can access those information on gRPC contexts in service B?

like image 817
Kayvan Mazaheri Avatar asked May 03 '26 03:05

Kayvan Mazaheri


1 Answers

Since you are changing the python object itself, it is not currently possible to pass it in the gRPC call. although you can do this manually by setting your metadata using send_initial_metadata method of your context and writing a new interceptor in service B to parse this information stored in invocation_metadata and setting it in the context of your second service.

like image 66
Borna Arzi Avatar answered May 04 '26 17:05

Borna Arzi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!